Dead code detection tools analyze your codebase and report code that is never executed or referenced. The right tool depends on your language, project size, and workflow. This guide covers the best options available in 2025.
1. ts-prune (TypeScript)
ts-prune finds unused exports in TypeScript projects by analyzing the import graph.
How it works: ts-prune reads your tsconfig.json, builds a dependency graph of all imports and exports, and reports any export that is never imported by another file.
npx ts-prune
Best for: TypeScript projects that need a quick, focused check for unused exports.
Limitations: Only detects unused exports. Does not find unused imports, local variables, or unreachable code. TypeScript only.
Price: Free, open source.
2. ESLint (JavaScript / TypeScript)
ESLint is primarily a linter, but its no-unused-vars rule is one of the most effective dead code detectors for per-file analysis.
How it works: ESLint parses each file and checks whether every declared variable, function parameter, and import is referenced within that file.
{
"rules": {
"@typescript-eslint/no-unused-vars": ["error", {
"argsIgnorePattern": "^_",
"varsIgnorePattern": "^_"
}]
}
}
Best for: Catching unused imports and variables on every save or in CI. Pairs well with ts-prune for project-wide export analysis.
Limitations: Per-file only. Cannot detect if an exported function is unused across the project. Requires configuration.
Price: Free, open source.
3. Periphery (Swift)
Periphery is the gold standard for dead code detection in Swift projects. It analyzes your entire Xcode project or Swift Package Manager package.
How it works: Periphery builds your project using xcodebuild or swift build, then analyzes the index store to find declarations that are never referenced.
periphery scan --project MyApp.xcodeproj --schemes MyApp --targets MyApp
Best for: iOS, macOS, and server-side Swift projects. Detects unused classes, structs, protocols, functions, properties, and enum cases.
Limitations: Requires Xcode (macOS only). Build times can be long for large projects. Configuration can be complex for multi-target projects.
Price: Free, open source.
4. Vulture (Python)
Vulture finds unused code in Python projects using AST analysis.
How it works: Vulture parses Python files into abstract syntax trees and reports functions, classes, variables, and imports that are defined but never used.
vulture src/ --min-confidence 80
Best for: Python projects of any size. The confidence score helps filter out false positives from dynamic code patterns.
Limitations: Python's dynamic nature means some code that appears unused may actually be called via getattr(), decorators, or string-based dispatch. The confidence threshold helps, but manual review is still needed.
Price: Free, open source.
5. CleanAI (Multi-Language)
CleanAI is a VS Code and Cursor extension that combines ts-prune, ESLint, Periphery, and Vulture into a single scan with a visual UI and automated removal.
How it works: CleanAI detects your project's languages, runs the appropriate analysis tools, merges the results, and presents them in a webview panel. You can remove findings one by one or use Auto Clean (Safe) to remove them incrementally with build verification.
Best for: Teams working across multiple languages who want a unified dead code solution with IDE integration. Especially useful for projects that combine TypeScript frontends with Swift mobile apps or Python backends.
Limitations: Requires VS Code or Cursor. Free tier has scan limits. Depends on underlying tools being available (e.g., Periphery needs Xcode).
Price: Free tier with limited scans. Paid plans for unlimited scanning.
Comparison Table
| Tool | Languages | Detects | IDE Integration | Auto-Remove | Price | |------|-----------|---------|-----------------|-------------|-------| | ts-prune | TypeScript | Unused exports | No | No | Free | | ESLint | JS/TS | Unused imports, vars | Yes (plugin) | Yes (--fix) | Free | | Periphery | Swift | All unused declarations | No | No | Free | | Vulture | Python | Unused code | No | No | Free | | CleanAI | TS/JS/Swift/Python | All of the above | VS Code/Cursor | Yes (safe) | Freemium |
Recommended Setup
For most teams, the best approach combines multiple tools:
- ESLint in CI -- catches unused imports and variables on every pull request
- ts-prune in CI -- catches unused exports on every pull request (TypeScript projects)
- CleanAI in the editor -- provides a visual overview and safe removal workflow for periodic deep cleans
- Periphery or Vulture as needed -- for Swift or Python projects, either standalone or via CleanAI
The goal is to catch dead code early (in CI) and clean it up efficiently (in the editor). No single tool covers everything, but the right combination gives you comprehensive coverage with minimal effort.