npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

pkg-lens

v0.1.2

Published

Zero-config CLI to detect and visualize dependency bloat in JS projects

Downloads

13

Readme

pkg-lens

Zero-config CLI to detect dependency bloat, dependency drift, and offline supply-chain risk in JavaScript/TypeScript projects.

npx pkg-lens

No installation required. Within seconds you'll see which packages are bloated, how many lines of code they contribute, what they can be replaced with, and how your dependency tree changed over time.

Why

JavaScript dependency trees carry significant dead weight:

  • The average npm package pulls in 85+ sub-dependencies
  • Many packages still ship compatibility layers for engines nobody uses
  • Hundreds of micro-packages exist as 3–20 line wrappers around native APIs
  • Ponyfills for features natively available since 2017–2019 are still widely installed
  • Every unnecessary package is a security supply chain risk

Existing tools like knip, e18e CLI, and bundlephobia solve adjacent problems — but none combine LOC counting + bloat classification + local tree analysis in one place.

Features

  • Zero config — runs with no flags, auto-detects package manager and project root
  • LOC counting — counts actual lines of JavaScript/TypeScript per package
  • Bloat classification — categorizes packages as stale ponyfills, micro-packages, legacy compat, or duplicates
  • Replacement suggestions — cross-references the e18e module-replacements dataset
  • Dependency chains — traces who pulled in each flagged package
  • Git drift analysis — compares dependency changes against another branch
  • Dependency blame — finds the commits that introduced or changed a package
  • Branch auditing — checks dependency drift across active local branches
  • Offline supply-chain risk scan — reports declared maintainer identities, single/missing-maintainer packages, and likely private-scope registry gaps
  • Offline-first — works from your lockfile, node_modules, and Git history; no registry lookups
  • Lean — under 10 direct dependencies (it would be embarrassing for a bloat-detection tool to have 200)

Usage

# Scan current directory for dependency bloat
npx pkg-lens

# Scan a specific project
npx pkg-lens --dir /path/to/project

# Output as JSON (for piping or CI)
npx pkg-lens --json

# Filter by bloat type
npx pkg-lens --only ponyfill    # only stale ponyfills
npx pkg-lens --only micro       # only micro-packages
npx pkg-lens --only compat      # only legacy compat
npx pkg-lens --only duplicate   # only duplicates

# Minimum LOC threshold
npx pkg-lens --min-loc 5        # only packages above 5 LOC

# Include offline security metrics with the default scan
npx pkg-lens --security

# Run only the offline supply-chain risk audit
npx pkg-lens security
npx pkg-lens security --json

# Compare current dependency tree against another branch
npx pkg-lens compare main
npx pkg-lens compare HEAD

# Find who introduced or changed a dependency
npx pkg-lens blame picocolors

# Audit dependency drift across active local branches
npx pkg-lens branches

# Launch browser UI (coming in v0.2.0)
npx pkg-lens --ui

Commands

| Command | What it does | Notes | |---|---|---| | pkg-lens / pkg-lens scan | Runs the default bloat scan | Supports --json, --only, --min-loc, --security | | pkg-lens security / pkg-lens sec | Runs the offline supply-chain risk audit | Requires node_modules | | pkg-lens compare [branch] | Compares current lockfile against another branch | Requires Git and a committed lockfile on the target branch | | pkg-lens blame <package> | Searches lockfile history for package changes | Requires Git history for the lockfile | | pkg-lens branches | Audits dependency drift across recent local branches | Reads lockfiles from local branch history |

Output: Bloat Scan

pkg-lens v0.1.0 — analyzing: my-app (847 packages)

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  STALE PONYFILLS  12 packages · ~18k LOC removable
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  globalthis        18 LOC  →  globalThis (native since 2019)
  ↳ your-app → babel-preset-env → es-abstract → globalthis

  object.entries    32 LOC  →  Object.entries() (native since 2017)
  ↳ your-app → eslint-plugin-react → object.entries

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  MICRO-PACKAGES  34 packages · could be inlined
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  shebang-regex      3 LOC  single consumer: shebang-command
  path-key           9 LOC  single consumer: npm-run-path

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  847 packages scanned · 46 flagged · 761 clean

Output: Security Audit

pkg-lens — SUPPLY CHAIN SECURITY AUDIT

Project: my-app (693 total dependencies analyzed)

Supply Chain Surface Area:
  • 185 unique maintainer identities are declared by installed packages.
  • 688 packages have one or no declared maintainer identities.

Dependency Confusion Checks:
  ✔ All custom scoped packages are correctly configured in .npmrc or match public scopes.

Single/Missing-Maintainer Packages:
  @emotion/[email protected]
  @mui/[email protected]
  ... and more

The security audit is intentionally offline and conservative. It inspects installed package metadata, local .npmrc, package.json, and lockfiles. It does not query npm or claim to replace a vulnerability database scanner.

Bloat Types

| Type | Description | Example | |---|---|---| | Stale Ponyfill | Native replacement exists | globalthis → globalThis | | Micro-Package | Under 20 LOC, could be inlined | path-key, shebang-regex | | Legacy Compat | Supports very old engines | has, hasown, es-abstract | | Duplicate | Multiple versions in tree | is-wsl v2.2.0 and v3.1.0 |

How It Works

  1. Scans node_modules — walks all .js, .mjs, .cjs, .ts files per package
  2. Counts LOC — non-empty, non-comment lines only
  3. Parses your lockfile — supports npm, pnpm, and yarn formats
  4. Classifies bloat — cross-references against the e18e module-replacements dataset
  5. Traces dep chains — shows exactly who pulled in each flagged package
  6. Reads Git history — powers compare, blame, and branches without shell interpolation
  7. Audits installed package metadata — powers offline supply-chain risk reporting

Comparison

| Tool | What it does | What it misses | |---|---|---| | pkg-lens | LOC + bloat type + dep chains + replacements | — | | knip | Finds unused deps/exports | No bloat classification, no LOC | | e18e CLI | Flags replaceable direct deps | CLI only, no visualization, no LOC | | bundlephobia | Shows bundle KB per package | Not local tree, no bloat typing | | depcheck | Finds unused deps | Archived, no bloat analysis |

Requirements

  • Node.js 18+
  • A project with node_modules installed
  • A lockfile (package-lock.json, pnpm-lock.yaml, or yarn.lock) for dependency chain info
  • Git installed and a committed lockfile for compare, blame, and branches

Roadmap

  • v0.2.0 — Interactive browser UI with sortable tables, filters, and dependency graph visualization
  • Future — CI/CD integration mode, config file for ignoring packages, richer vulnerability database integrations

License

MIT