| name | ts-prune |
| description | Find and remove unused TypeScript imports. Use when auditing TypeScript/JavaScript projects to identify dead code and clean up import statements. |
ts-prune — TypeScript Pruner
Basic Usage
ts-prune
ts-prune --dir ./src
ts-prune --dry-run
Common Options
ts-prune --format table
ts-prune --format json
ts-prune --format csv
ts-prune --remove
ts-prune --ignore=node_modules,dist,.next
Output Fields
| Field | Description |
|---|
file | File path with unused import |
import | The unused import statement |
type | "import" or "type" |
When to Use
- TypeScript audit — find unused imports/dead code
- Clean up
import statements in a codebase
- Identify which modules are truly used vs. legacy code
- Compare code cleanliness metrics against benchmarks
Examples
ts-prune --format json > ts-prune.json
ts-prune --dry-run
ts-prune --remove
Note
ts-prune works on TypeScript projects. For JavaScript-only projects, use depcheck instead.