npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

analyze-codebase

v1.3.2

Published

A powerful CLI tool for analyzing codebase structure, naming conventions, code quality metrics, and detecting unused i18n translation keys

Downloads

159

Readme


A zero-config CLI that scans your entire project in seconds and gives you a clear picture of what's inside: file structure, naming conventions, code-vs-comment ratios, and most uniquely, unused i18n translation keys that bloat your bundles.

npx analyze-codebase ./src

That's it. No config needed.

Why analyze-codebase?

| Problem | Solution | |---------|----------| | "How consistent are our naming conventions?" | Detects 13+ naming cases (camelCase, PascalCase, kebab-case, snake_case...) | | "How much of our code is actually comments?" | Breaks down physical lines, source code, comments, TODOs, empty lines | | "We have hundreds of translation keys. Which ones are unused?" | Scans your entire codebase for unused i18n keys and safely removes them | | "I need a report for my team" | Export as HTML, CSV, or JSON with one flag | | "I want this running in my workflow" | Watch mode, CI/CD friendly, config file support |

Quick Start

# Install globally
npm install -g analyze-codebase

# Or run instantly with npx
npx analyze-codebase .

Find unused i18n translation keys

# With npx (no install needed)
npx analyze-codebase i18n ./src --file locales/en.json

# If installed globally
analyze-codebase i18n ./src --file locales/en.json

# Vue project example
analyze-codebase i18n ./src --file public/locales/en.json --extensions ts tsx vue

# With exclusions
analyze-codebase i18n . --file messages/en.json --exclude dist public

The tool will show all unused keys, then ask y/n before removing them. Safe to run — nothing is deleted without confirmation.

Setup a config file (optional)

analyze-codebase init

This creates .analyze-codebase.json in your project root with your preferred settings. After that, just run analyze-codebase - it auto-discovers your config.

Features

1. Codebase Structure Analysis

Recursively scans your project and provides a breakdown of:

  • File naming conventions - Are your files consistently named? camelCase? PascalCase? kebab-case? You'll see the exact distribution.
  • Code content metrics - Physical lines, source code lines, comments, block comments, single-line comments, TODOs, empty lines.
  • Smart defaults - Automatically excludes node_modules, dist, build, coverage, .git, .next, public, test, tests, mocks.
# Analyze TypeScript files in your src directory
analyze-codebase ./src --extensions ts tsx

# Analyze with a specific framework tag
analyze-codebase ./src -f react --extensions ts tsx js jsx

Tip: Extensions work with or without the dot prefix - both ts and .ts are accepted.

2. Unused i18n Translation Key Detection

This is the feature that sets analyze-codebase apart. If you work with internationalization, you know the pain: translation files grow over time, keys get orphaned, and nobody knows which ones are still in use.

analyze-codebase ./src --i18n-file locales/en.json

What it does:

  1. Parses your translation JSON (supports deeply nested structures)
  2. Flattens all keys to dot-notation paths (e.g., common.buttons.submit)
  3. Scans every source file in your project for usage
  4. Shows you exactly which keys are unused
  5. Asks for confirmation, then safely removes them

Supported patterns - it understands how real apps use translations:

// All of these are detected:
t('key')                    // react-i18next, i18next
t("key")                    // double quotes
t(`key`)                    // template literals
i18n.t('key')               // direct i18n object access
$t('key')                   // Vue i18n
translate('key')            // custom translate functions

// Even dynamic keys:
t(`namespace.${variable}`)  // template literal interpolation
t('namespace.' + variable)  // string concatenation

When dynamic keys are detected, all child keys under that namespace are automatically marked as used - preventing false positives.

3. Export Reports

Generate shareable reports in three formats:

# Beautiful styled HTML report
analyze-codebase ./src --export html --output report.html

# Spreadsheet-friendly CSV
analyze-codebase ./src --export csv --output data.csv

# Structured JSON for programmatic use
analyze-codebase ./src --export json --output results.json

The HTML report includes styled tables, gradient headers, and is ready to share with your team or stakeholders.

4. Watch Mode

Automatically re-runs analysis whenever files change. Perfect for development:

analyze-codebase ./src --watch
  • 500ms debounce to prevent excessive runs
  • Graceful Ctrl+C shutdown
  • Works with all analysis options

5. Parallel Processing

Files are processed in parallel with auto-optimized concurrency:

| Project Size | Default Concurrency | |-------------|-------------------| | < 100 files | 20 concurrent ops | | 100-500 files | 25 concurrent ops | | 500+ files | 30 concurrent ops |

# Override if needed
analyze-codebase ./src --max-concurrency 50

All CLI Options

Usage: analyze-codebase [directory] [options]

Options:
  -f, --framework <name>          Tag the framework (react, vue, angular...)
  -e, --extensions <ext...>       File extensions to include (ts tsx js jsx)
  -exc, --exclude <dirs...>       Additional directories to exclude
  --checkFileNames [bool]         Analyze file naming conventions (default: true)
  --checkFileContent [bool]       Analyze code content metrics (default: true)
  -w, --writeJsonOutput [bool]    Write JSON output to track changes over time
  --i18n-file <path>              Path to i18n JSON file for unused key detection
  --watch                         Re-analyze automatically on file changes
  --no-progress                   Disable progress bar (useful for CI/CD)
  --max-concurrency <number>      Max parallel file operations (default: auto)
  --export <format>               Export as json, csv, or html
  --output <path>                 Output file path for export

Commands:
  init                            Create .analyze-codebase.json interactively

Config File

Create .analyze-codebase.json in your project root (or run analyze-codebase init):

{
  "extensions": [".ts", ".tsx", ".js", ".jsx"],
  "exclude": ["node_modules", "dist", "build"],
  "checkFileNames": true,
  "checkFileContent": true,
  "framework": "react",
  "showProgress": true,
  "parallel": true
}

The config is auto-discovered by searching up the directory tree. CLI flags always take precedence over config values.

Real-World Examples

Code Review Preparation

# Get a full picture before a code review
analyze-codebase ./src --extensions ts tsx --export html --output review.html

CI/CD Pipeline

# Silent mode for CI - just export the data
analyze-codebase ./src --no-progress --export json --output analysis.json

Translation Cleanup Sprint

# Find and remove all unused translation keys
analyze-codebase ./src --i18n-file public/locales/en.json --extensions ts tsx

Monorepo Analysis

# Analyze specific packages
analyze-codebase ./packages/web --extensions ts tsx -f react
analyze-codebase ./packages/api --extensions ts -f express

Contributing

Contributions are welcome! Here's how:

  1. Fork the repository
  2. Create your branch: git checkout -b feature/amazing-feature
  3. Make your changes and test them: npm test
  4. Commit: git commit -m "feat: add amazing feature"
  5. Push: git push origin feature/amazing-feature
  6. Open a Pull Request

License

MIT - see LICENSE for details.