Find unused exports, functions, and dead code in JavaScript/TypeScript projects.
Clean up your codebase. Know what's actually used.
# Use directly with npx (recommended)
npx @lxgicstudios/deadcode
# Or install globally
npm install -g @lxgicstudios/deadcode# Scan current directory
npx @lxgicstudios/deadcode
# Scan specific directory
npx @lxgicstudios/deadcode src/
# Ignore patterns
npx @lxgicstudios/deadcode --ignore test --ignore mock
# JSON output for CI
npx @lxgicstudios/deadcode --json > dead-code-report.json
# Quiet mode (just counts)
npx @lxgicstudios/deadcode -qℹ Scanning src/ for dead code...
ℹ Scanned 47 files
ℹ Found 234 exports, 189 imports
⚠ Found 12 potentially unused exports:
src/utils/helpers.ts
L15: function formatDate
L42: const DEPRECATED_CONFIG
src/components/OldButton.tsx
L8: class OldButton
src/types/legacy.ts
L3: interface LegacyUser
L12: type OldConfig
Note: Some exports may be used dynamically or externally. Review before deleting.
- ✅ Exported functions that are never imported
- ✅ Exported constants that are never used
- ✅ Exported classes that are never instantiated
- ✅ Exported types/interfaces that are never referenced
- ✅ Re-exports that go nowhere
- 📁
node_modules,dist,builddirectories - 📄 Index files (usually re-export hubs)
- 🧪 Test files (
.test.ts,.spec.ts) - ⚙️ Config files
| Option | Description |
|---|---|
-d, --dir <path> |
Directory to scan (default: cwd) |
-i, --ignore <pattern> |
Ignore files matching pattern |
--json |
Output as JSON |
-q, --quiet |
Only show counts |
-h, --help |
Show help |
# .github/workflows/deadcode.yml
- name: Check for dead code
run: npx @lxgicstudios/deadcode --json > report.json
continue-on-error: trueimport { findDeadCode, getCodeFiles, extractExports } from '@lxgicstudios/deadcode';
// Full scan
const result = findDeadCode('./src', { ignorePatterns: ['test'] });
console.log(result.unusedExports);
// Just get files
const files = getCodeFiles('./src');
// Extract exports from a file
const exports = extractExports(fileContent, filePath);Built by LXGIC Studios