bundlephobia-tool is a CLI for checking npm package bundle size, gzip size, dependency weight, version history, and similar packages from the terminal.
Status: Maintained public CLI. The repository and npm package are both at the verified 1.3.6 release.
If you have ever searched for:
bundlephobia clinpm package size checkerhow to check bundle size of a package from terminalanalyze package.json dependencies by size
this is the tool for that job.
Bundlephobia is excellent, but opening a browser tab for every package breaks flow. This CLI keeps the same idea inside the terminal so you can evaluate dependencies while coding, reviewing a pull request, or guiding an AI agent through a repo.
It is useful for:
- Frontend engineers comparing packages before adding a dependency
- Library maintainers watching bundle cost over time
- PR reviewers looking for unexpectedly heavy packages
- CI scripts that should fail when analysis fails
- LLM and agent workflows that need a simple terminal-native package size check
- Analyze a single npm package with minified and gzipped size
- Show richer package metadata like license, downloads, homepage, and repository
- List similar packages using Bundlephobia's recommendations
- Show recent analyzed version history for a package
- Scan a local
package.jsonand rank dependencies by size - Retry transient API failures and use safer batching to reduce rate limits
Runtime support:
- Node.js 20+
- Bun 1+
Install globally:
npm install -g bundlephobia-toolor:
bun install -g bundlephobia-toolOr run it without installing:
npx bundlephobia-tool analyze reactThe installed command is:
pkg-sizeCheck one package:
pkg-size analyze reactShow more package details:
pkg-size analyze react --infoSee similar packages:
pkg-size analyze react --similarInspect recent version history:
pkg-size analyze react --historyAnalyze dependencies in the current project:
pkg-size depsInclude devDependencies too:
pkg-size deps --allAnalyze a single npm package. Works with package names, exact versions, and semver ranges that Bundlephobia understands.
Examples:
pkg-size analyze react
pkg-size analyze [email protected]
pkg-size analyze commander@^14.0.2Options:
-r, --raw: print the raw Bundlephobia size response as JSON-i, --info: show package metadata plus bundle size-d, --dependencies: show the package's dependency size breakdown-s, --similar: show similar packages and size data when available--history: show recent analyzed versions from Bundlephobia
Open the package's Bundlephobia result page in your default browser.
pkg-size open reactAnalyze the dependencies in a package.json file and print the heaviest packages first.
Examples:
pkg-size deps
pkg-size deps --all
pkg-size deps --path ./apps/web/package.json
pkg-size deps --path ./apps/webOptions:
-a, --all: includedevDependencies-p, --path <path>: path to apackage.jsonfile or a directory containing one
Notes:
@types/*packages are skipped automaticallyworkspace:,file:,link:,portal:,patch:,git:,git+,github:, and URL-based dependencies are skipped because they cannot be analyzed reliably through Bundlephobianpm:aliases are supported
Single package:
$ pkg-size analyze react
react v19.2.4
• 7.4 kB minified
• 2.9 kB gzipped
Detailed package info:
$ pkg-size analyze react --info
react v19.2.4
React is a JavaScript library for building user interfaces.
• Bundle size: 7.4 kB minified, 2.9 kB gzipped
• License: MIT
• Downloads: 360,786,955 (last 30 days)
• Homepage: https://react.dev/
• Repository: https://github.com/facebook/react
Dependency scan:
$ pkg-size deps
react-dom v19.2.0
• 16.1 kB minified
• 5.2 kB gzipped
react v19.2.4
• 7.4 kB minified
• 2.9 kB gzipped
✔ 2 packages analyzed, 0 failed, 0 skipped
Total size: 23.5 kB minified, 8.1 kB gzipped
Actual package versions and sizes change over time. The commands above are the stable part.
Use:
pkg-size analyze <package-name>Example:
pkg-size analyze lodashRun:
pkg-size depsThis reads your local package.json, queries Bundlephobia for each supported dependency, and prints the largest dependencies first.
Yes. Commands now exit with a non-zero status when analysis fails, which makes the tool usable in scripts and automation.
Yes. The CLI is intentionally simple:
- one package:
pkg-size analyze react - project dependencies:
pkg-size deps - similar alternatives:
pkg-size analyze react --similar - browser fallback:
pkg-size open react
That makes it easy for an LLM agent to answer prompts like:
Find the heaviest dependency in this repoCheck whether this new package is lightweightSuggest smaller alternatives to this dependency
The tool uses:
- Bundlephobia for package size, dependency breakdowns, similar packages, and package history
- npm registry APIs for package metadata and 30-day download counts
An internet connection is required.
- Retries transient failures
- Uses timeouts for network calls
- Batches dependency analysis conservatively to avoid API rate limits
- Falls back gracefully when some similar-package lookups do not return size metadata
Install dependencies:
bun installRun locally:
bun run src/cli.ts analyze reactBuild the distributable:
bun run buildRun tests:
bun test
bun run build
bun run dist/cli.js --helpIssues and pull requests are welcome.
If you want to improve package discovery, output formats, or CI integration, open an issue with a concrete use case.
MIT