ScriptsApr 6, 2026·2 min read

Tokei — Fast Code Statistics for Any Language

Blazing-fast code statistics tool written in Rust. Count lines of code, comments, and blanks across 200+ languages. Perfect for project health reports and AI context. 12,000+ stars.

TL;DR
Tokei counts lines of code, comments, and blanks across 200+ languages in milliseconds, written in Rust.
§01

What it is

Tokei is a code statistics tool written in Rust that counts lines of code, comments, and blanks across 200+ programming languages. It runs in milliseconds even on large codebases and outputs clean tables showing the breakdown by language and file. It provides fast, accurate metrics for project health reports and AI context.

It is designed for developers, tech leads, and CI pipelines that need quick codebase metrics without the overhead of full static analysis tools.

§02

How it saves time or tokens

The token estimate for this workflow is 2,200 tokens. Running tokei in a project directory gives you an instant snapshot of codebase composition. For AI agents, this provides essential context (language distribution, project size) in a single command rather than manual file counting or guessing.

§03

How to use

  1. Install: brew install tokei (macOS) or cargo install tokei (any platform)
  2. Run tokei in your project directory
  3. View the language-by-language breakdown of code, comments, and blanks
§04

Example

# Install
brew install tokei  # macOS
cargo install tokei  # any platform with Rust

# Count lines in current project
tokei

# Output:
# ===============================================================================
#  Language            Files        Lines         Code     Comments       Blanks
# ===============================================================================
#  TypeScript             45         3420         2810          280          330
#  Python                 12          980          820           60          100
#  JSON                    8          450          450            0            0
# ===============================================================================
#  Total                  65         4850         4080          340          430
# ===============================================================================

# Exclude directories
tokei --exclude node_modules --exclude .git

# Output as JSON for programmatic use
tokei --output json

# Sort by lines of code
tokei --sort code
§05

Related on TokRepo

§06

Common pitfalls

  • Tokei counts by file extension; files without extensions or with non-standard extensions may be misclassified or skipped
  • Generated files (node_modules, build outputs) inflate counts; use --exclude to filter them
  • Comment counting accuracy depends on Tokei's language parser; some complex comment syntaxes may be miscounted

Frequently Asked Questions

How fast is Tokei compared to alternatives?+

Tokei is written in Rust and processes large codebases in milliseconds. It is significantly faster than tools like cloc (Perl) or scc (Go), especially on projects with thousands of files.

Does Tokei support my programming language?+

Tokei supports 200+ languages out of the box, including all major languages and many niche ones. Check the languages.json file in the Tokei repository for the complete list.

Can I use Tokei output in CI pipelines?+

Yes. Use the --output json flag to get machine-readable output. You can parse this in CI scripts to track codebase growth, enforce size limits, or generate reports automatically.

Does Tokei count generated code separately?+

Tokei does not distinguish between hand-written and generated code. Use --exclude to filter out generated directories like node_modules, dist, or vendor before running.

How do I install Tokei without Rust?+

On macOS use brew install tokei. Pre-built binaries are available on the GitHub releases page for Linux and Windows. You do not need the Rust toolchain for binary installation.

Citations (3)
  • Tokei GitHub— Tokei is a fast code statistics tool written in Rust supporting 200+ languages
  • Tokei README— Supports JSON output for programmatic use
  • Tokei Comparison— Comparison of code counting tools
🙏

Source & Thanks

Created by XAMPPRocky. Licensed under MIT/Apache 2.0.

tokei — ⭐ 12,000+

Thanks for making codebase statistics instant.

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.

Related Assets