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.
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.
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.
How to use
- Install:
brew install tokei(macOS) orcargo install tokei(any platform) - Run
tokeiin your project directory - View the language-by-language breakdown of code, comments, and blanks
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
Related on TokRepo
- AI Tools for Coding -- Developer tools for codebase analysis
- Featured Workflows -- Top-rated workflows on TokRepo
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
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.
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.
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.
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.
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
Related on TokRepo
Source & Thanks
Created by XAMPPRocky. Licensed under MIT/Apache 2.0.
tokei — ⭐ 12,000+
Thanks for making codebase statistics instant.
Discussion
Related Assets
NAPI-RS — Build Node.js Native Addons in Rust
Write high-performance Node.js native modules in Rust with automatic TypeScript type generation and cross-platform prebuilt binaries.
Mamba — Fast Cross-Platform Package Manager
A drop-in conda replacement written in C++ that resolves environments in seconds instead of minutes.
Plasmo — The Browser Extension Framework
Build, test, and publish browser extensions for Chrome, Firefox, and Edge using React or Vue with hot-reload and automatic manifest generation.