Find unused exports in your TypeScript project — dead code that's exported but never imported anywhere.
Your index.ts exports 50 things. Half of them haven't been used in months. They add noise, confuse newcomers, and bloat your bundle. tsprune tells you exactly which exports are gathering dust.
Unlike general dead code tools, tsprune focuses specifically on the export boundary — things you've chosen to make public. If nobody's using them, why are they exported?
npm install -g tsprune# Scan current directory
tsprune .
# Scan specific path
tsprune src
# JSON output for scripts/CI
tsprune . --json
# Markdown report
tsprune . --markdown
# Skip type-only exports (interfaces, type aliases)
tsprune . --ignore-typesFound 3 unused exports in 12 files
src/utils/format.ts
→ formatDate (function) line 14
→ parseDate (function) line 28
src/types.ts
→ LegacyConfig (interface) (type) line 45
Summary: 3/47 unused (6%)
Exit codes:
0— no unused exports found1— unused exports found (CI-friendly)
# GitHub Actions
- name: Check for unused exports
run: npx tsprune src --ignore-typesThe --json flag gives you a full report you can process further:
tsprune . --json | jq '.unused[] | .name'- Scans your project for
.ts/.tsx/.js/.jsxfiles (skipsnode_modules,dist,.git, test files,.d.ts) - Parses all
exportdeclarations - Parses all
importdeclarations - Resolves relative import paths to actual files
- Matches imports to exports
- Anything exported but never imported = unused
export functionexport classexport const/let/varexport typeexport interfaceexport enumexport defaultexport { ... }named groups- Re-exports with aliases (
export { foo as bar })
- Only tracks relative imports (
./,../). Package imports fromnode_modulesare not resolved. - Dynamic imports (
import()) and re-exports (export * from) are partially handled. - If you use path aliases (e.g.,
@/utils), configure your resolver separately. tsprune works with plain relative paths.
import { scan, formatTable, formatJson, formatMarkdown } from "tsprune";
const result = scan("./src", { ignoreTypes: true });
console.log(formatTable(result));
// or
console.log(formatJson(result));
// or
console.log(formatMarkdown(result));MIT