Skip to main content

depsnap

Find the dependencies you can safely delete. Your package.json collects cruft — a package you stopped importing six refactors ago is still installed, still audited, still slowing npm install. depsnap finds the ones referenced nowhere in your code, config, or scripts. Conservative by design, zero config, zero dependencies.

pip install depsnap
depsnap
depsnap — 1 unused dependency in demo-app (of 3 checked)

  ● left-pad  dependencies  no import or script reference

Verify before removing — depsnap only flags names it found nowhere · 1 @types/* skipped.

Why another one

depcheck was the go-to for years, but it was archived in 2025 with a long tail of false-positive bugs — TypeScript type-only imports, subpath imports, peer deps, @types/* stubs all getting wrongly flagged as "unused". knip is the powerful successor, but it's a ~150-plugin tool built for big codebases; sometimes you just want a five-second answer to "what's safe to delete?"

depsnap takes the opposite bet from depcheck: instead of trying to prove a dependency is used (and getting it wrong on edge cases), it only flags a package when its name appears nowhere — no import, no require, no dynamic import(), no string in a config file, no CLI in an npm script. Every result is high-confidence removable.

That means it handles the cases depcheck botched, for free:

Case depcheck depsnap
import type { X } from 'pkg' often flagged unused seen as used
import 'pkg/subpath' sometimes missed seen as used
await import('pkg') sometimes missed seen as used
@types/* stubs flagged unused skipped by default
CLI used only in an npm script (tsc) flagged unused seen as used (reads node_modules bins)
peer dependencies flagged unused not checked

The trade-off is honest: depsnap won't catch a dependency you import but never actually call — that needs full reachability analysis. For that, reach for knip. depsnap is the fast first pass.

Usage

depsnap                 # check ./package.json against this project
depsnap path/to/pkg     # check a project in another directory
depsnap --dev           # also check devDependencies
depsnap --format json   # machine-readable output

Try it on the bundled example after cloning:

python -m depsnap examples/demo        # → flags left-pad
python -m depsnap examples/demo --dev    # → also flags unused-dev-tool

How it works

  1. Reads package.json for your declared dependencies.
  2. Walks your project (skipping node_modules, dist, .git, etc.) and builds a corpus of every .js/.ts/.jsx/.tsx/.vue/.svelte/.json/.yaml/... and dotfile config — but never package.json or a lockfile, since those list every dependency by name and would mask everything.
  3. For each dependency, checks whether its name (with import-aware word boundaries, so lodash ≠ lodash-es) appears anywhere in that corpus, in the npm scripts, or as one of its installed node_modules bin names.
  4. Reports the ones that appear nowhere.

In CI

depsnap exits non-zero when it finds unused dependencies, so it can keep cruft from creeping back in:

- run: npx depsnap --dev
Exit code Meaning
0 no unused dependencies
1 unused dependencies found
2 error (no package.json, bad arguments)

Options

--dev               also check devDependencies (default: dependencies only)
--include-types     also check @types/* packages (default: skipped)
--format text|json  output format (default: text)
-v, --version
-h, --help

Scope

Single-package projects. Workspaces/monorepos aren't resolved across packages yet (run it per-package). It reads package.json dependencies/devDependencies; peerDependencies and optionalDependencies are intentionally left alone.

Also available for Node

npx depsnap

Same checks, same flags, same exit codes — depsnap on npm.

Note: depsnap reads package.json and your source, so it works on any JS/TS project regardless of which language you install it from.

License

MIT

Metadata

Release files for depsnap 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for depsnap 0.1.0
File Size Uploaded Provenance Actions
depsnap-0.1.0.tar.gz 11.2 kB Without provenance Details for depsnap-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for depsnap 0.1.0
File Interpreter ABI Platform Actions
depsnap-0.1.0-py3-none-any.whl Python 3 none any Details for depsnap-0.1.0-py3-none-any.whl

Total release size: 20.9 kB

Release files / depsnap-0.1.0.tar.gz

Download URL depsnap-0.1.0.tar.gz
Size 11.2 kB
Tags Source
SHA-256 checksum
How to use checksums
c4f2a4e803e6be0e7fc4e02d0e6d081d2ab6560caada1b02e49575202db8be12
BLAKE2b-256 checksum
How to use checksums
3adf5ffc5ea4926c630b79ab4513af7a9c4cca17e87923c0dae8e313bdef21ae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.7

Release files / depsnap-0.1.0-py3-none-any.whl

Download URL depsnap-0.1.0-py3-none-any.whl
Size 9.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8212cff1807b8189f1556bcc44c0d6fbc305c10f8e82426ca1c72a2f09bb7611
BLAKE2b-256 checksum
How to use checksums
80f4f6365c44adac7c664c5e30a07f5d4263b6bf0b8f3e8454c0017c79ac4d64
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.7

Security for depsnap 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page