Skip to content
Latchkey

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.

Knipdepcheck
ScopeUnused files, exports, types, depsUnused + missing deps
Language focusJS/TS (TypeScript-aware)JS/TS
Monorepo supportFirst-class (workspaces)Limited
Configknip.json / knip.ts, many pluginsLightweight config
False positivesFewer with plugins, tunableMore on complex setups
MaintenanceActively developedStable, 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.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →