Knip is a dead code detection tool built specifically for the JavaScript and TypeScript ecosystem. It performs whole-project analysis to find files that no other file imports, dependencies listed in package.json that no code actually uses, devDependencies that build scripts and test configs never reference, and named exports that nothing consumes. Unlike linters that check individual files in isolation, Knip builds a complete dependency graph of the entire project to make globally informed decisions about what is truly unused.
The tool understands the configuration formats of major frameworks and build tools including Next.js, Vite, Jest, ESLint, TypeScript, Storybook, and dozens of others. This means it recognizes that a dependency referenced only in a jest.config.ts is a used devDependency, not an unused one. The plugin system can be extended for custom configuration formats. Output formats include human-readable summaries, JSON for CI integration, and fix mode that can automatically remove identified dead code.
Knip has gained particular relevance in the era of AI-assisted development where coding agents generate code rapidly but rarely clean up after themselves. The accumulation of unused files, orphaned exports, and phantom dependencies degrades build times, increases bundle sizes, and creates confusion for both human and AI developers navigating the codebase. With over 10,800 GitHub stars and 100+ contributors, Knip is MIT licensed and has become an essential part of modern JavaScript project maintenance.