Knip vs depcheck: Find Unused Code and Dependencies
depcheck finds unused and missing npm dependencies; Knip does that and more, also reporting unused files, exports, and types across a project or monorepo.
Both tools help you prune dead weight from JavaScript/TypeScript projects. depcheck focuses narrowly on package.json dependencies; Knip is broader, covering unused files, exports, class members, and dependencies. Here is the honest comparison.
| Knip | depcheck | |
|---|---|---|
| Scope | Unused files, exports, types, deps | Unused + missing deps |
| Language focus | JS/TS (TypeScript-aware) | JS/TS |
| Monorepo support | First-class (workspaces) | Limited |
| Config | knip.json / knip.ts, many plugins | Lightweight config |
| False positives | Fewer with plugins, tunable | More on complex setups |
| Maintenance | Actively developed | Stable, lighter activity |
Narrow vs broad
depcheck answers one question well: which dependencies in package.json are unused, and which imported packages are missing. Knip covers that plus unused files and exports, which is where a lot of dead code actually hides. If you only care about dependency hygiene, depcheck is simpler; if you want a full dead-code sweep, Knip is more thorough.
Monorepos and accuracy
Knip has first-class workspace support and a plugin system that teaches it about frameworks and tools (Vite, Jest, ESLint, and more), which cuts false positives. depcheck can struggle with monorepos and dynamic imports. Both need some config to avoid flagging entry points or config-only dependencies.
In CI
Run either as a lint-style gate so unused dependencies and dead files do not accumulate. Start in a non-blocking mode to triage the initial backlog, then enforce once the baseline is clean.
The verdict
Choose depcheck for a lightweight, dependencies-only check; choose Knip for a broader dead-code audit with strong monorepo support. Many teams start with depcheck and graduate to Knip as the project grows.