Check npm package install size, dependency count, and bundle impact — before you
npm install.
Every npm install adds weight. Large dependencies slow down CI pipelines, bloat Docker images, increase serverless cold starts, and expand your attack surface. dep-size lets you check what you're about to add — size, dependencies, file count — in seconds, from your terminal.
npm install -g dep-size-cliOr run instantly with npx (no install needed):
npx dep-size-cli express lodash axios# Check a single package
dep-size express
# Compare multiple packages (sort by size!)
dep-size axios got node-fetch undici --sort
# Show dependency tree
dep-size express --tree --depth=2
# JSON output for scripts/CI
dep-size react --json
# CI gate: fail if package exceeds size threshold
dep-size my-lib --warn=500KB express@4.21.0
Size: 214.0 KB (unpacked)
Total: ~1.8 MB (with all deps)
Files: 72
Deps: 31 accepts, array-flatten, body-parser, content-disposition...
License: MIT
Dependency tree:
├── accepts@1.3.8 (5.3 KB)
│ ├── mime-types@2.1.35 (4.2 KB)
│ └── negotiator@0.6.3 (4.8 KB)
├── body-parser@1.20.3 (18.1 KB)
└── ...
- ⚡ Fast — queries npm registry directly, zero overhead
- 📦 Size check — see unpacked size before installing
- 🌳 Dependency tree — visualize what gets pulled in with
--tree - 📊 Total install size — estimated total including all transitive deps
- 🔢 Dependency count — know what you're pulling in
- 🔀 Compare & sort — side-by-side comparison with
--sort(largest first) - 🚨 CI gate —
--warn=SIZEexits with code 1 if threshold exceeded - 📋 JSON output — pipe into scripts and CI pipelines
- 🪶 Zero dependencies — just Node.js built-ins
| Flag | Description |
|---|---|
--json |
Output as JSON |
--tree |
Show dependency tree |
--depth=N |
Tree depth (default: 3) |
--sort |
Sort results by size (largest first) |
--warn=SIZE |
Exit 1 if any package exceeds threshold (e.g. 500KB, 1MB) |
Before picking an HTTP library, compare them:
dep-size axios got node-fetch undici --sortCheck every dependency in your project:
dep-size $(node -e "console.log(Object.keys(require('./package.json').dependencies).join(' '))")Prevent dependency bloat in your pipeline:
dep-size my-package --warn=2MB --jsonSee the full picture of what express pulls in:
dep-size express --tree --depth=3Audit deps before building production images — identify the heaviest packages and find lighter alternatives.
- name: Check dependency sizes
run: |
npx dep-size-cli my-package --warn=2MB
npx dep-size-cli $(node -e "console.log(Object.keys(require('./package.json').dependencies).join(' '))") --sort --json > dep-report.json
- name: Upload size report
uses: actions/upload-artifact@v4
with:
name: dependency-sizes
path: dep-report.json| Tool | What it does | Install size | Dependencies |
|---|---|---|---|
| dep-size | Check size before installing | tiny | 0 |
| packagephobia | Web-based size check | N/A (web) | N/A |
| bundlephobia | Bundle size (browser) | N/A (web) | N/A |
| cost-of-modules | Size of installed deps | large | many |
npm pack --dry-run |
Tarball size only | built-in | N/A |
dep-size is the only zero-dependency CLI that shows install size, dependency tree, and supports CI gating — all from your terminal.
Other zero-dependency CLI tools by kszongic:
- commitwiz-ai — AI-powered git commit messages
- npm-name-check — Check npm package name availability
- env-lint-cli — Lint .env files against .env.example
- license-maker — Generate LICENSE files from the CLI
MIT © kszongic
If this saved you time, consider sponsoring ⭐