Find unused files, dependencies and exports in JavaScript and TypeScript projects
open sourceISCself-hostablefreeMCP
Knip is a command-line linter that finds and fixes unused files, dependencies, devDependencies and exports in JavaScript and TypeScript projects and monorepos. It starts from entry points worked out from the frameworks and tools a project actually uses, through more than 200 plugins (Astro, Cypress, ESLint, Jest, GitHub Actions, Next.js, Nx, Storybook, Svelte, Vite, Vitest, Webpack and others), and also reports dependencies that are used but not listed, unlisted binaries, unresolved imports, unused catalog entries and duplicate exports. --fix removes much of what it finds, a production mode checks only shipped code, and reporters suit CI. A language server powers its VS Code extension and a community JetBrains plugin with inline diagnostics, import and export trees and warnings about circular imports, and an MCP server lets coding agents configure it. Lars Kappert created it, and it is ISC-licensed.
Problems it solves
- find files in my TypeScript project that nothing imports anymore
- find dependencies in package.json that my code no longer uses
- find exported functions and types that no other module imports
- catch packages my code imports that aren't listed in package.json
- clean up dead code across a pnpm or npm workspaces monorepo
- fail CI when someone adds an unused dependency or export
- automatically remove unused exports and dependencies from a JavaScript project
- a replacement for depcheck, ts-prune or unimported
- see in VS Code which exports are unused and where each one is imported
- detect circular imports in my TypeScript codebase
- let my coding agent set up dead-code detection for my project
Features
- reports unused files, dependencies, devDependencies, exports, exported types, enum and namespace members and package.json subpaths
- reports unlisted dependencies and binaries, unresolved imports, duplicate exports and, when included, circular dependencies
- unused and unresolved pnpm catalog entries
- 218 plugins that find entry points and config files for frameworks and tools
- monorepos and workspaces support
- production mode that ignores tests and dev tooling
- auto-fix with --fix
- rules, filters and JSDoc/TSDoc tags to tune what is reported
- reporters and preprocessors for CI output
- compilers for non-standard files such as Vue, Svelte, Astro and MDX
View 3 more
- language server behind the official VS Code and Open VSX extension (diagnostics, hover usage, import and export trees, warnings for circular imports) and a community JetBrains plugin
- MCP server (@knip/mcp) for coding agents
- online playground
Limitations
- Can fail on config files that don't load: plugins load files like vite.config.ts and stop with exit code 2 when one throws, for example over missing environment variables or path aliases1
Capabilities
| Has a command line tool | plan not known |
|---|---|
| Has an MCP server | plan not known |
| Takes plugins | plan not known |