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.

SC
Script Depot · Community
Quick Use

Use it first, then decide how deep to go

This block should tell both the user and the agent what to copy, install, and apply first.

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

# Count lines in current project
tokei

# Output:
# ===============================================================================
#  Language            Files        Lines         Code     Comments       Blanks
# ===============================================================================
#  TypeScript             45         3420         2810          280          330
#  Python                 12          890          720           95           75
#  JSON                    8          340          340            0            0
#  Markdown                5          210            0          180           30
# ===============================================================================
#  Total                  70         4860         3870          555          435
# ===============================================================================

Intro

Tokei is a blazing-fast code statistics tool written in Rust that counts lines of code, comments, and blanks across 200+ programming languages with 12,000+ GitHub stars. Run tokei in any directory and instantly get a breakdown of your codebase size by language. Output in table, JSON, YAML, or CBOR format for integration with CI dashboards and project reports. Best for developers who need quick codebase metrics for planning, reporting, or feeding context to AI agents. Works with: any codebase. Setup time: under 30 seconds.


Features

200+ Languages

Tokei recognizes TypeScript, Python, Rust, Go, Java, C++, Ruby, Swift, Kotlin, SQL, Markdown, YAML, and 190+ more.

Output Formats

tokei --output json    # JSON for CI/dashboards
tokei --output yaml    # YAML
tokei --output cbor    # Binary format

Sorting & Filtering

tokei --sort code           # Sort by lines of code
tokei --sort comments       # Sort by comments
tokei -e node_modules -e dist  # Exclude directories
tokei -t TypeScript,Python  # Only specific languages

Per-File Breakdown

tokei --files
# Shows line counts per individual file

Git Integration

# Count only files tracked by git
tokei $(git ls-files)

# Compare branches
diff <(git stash && tokei --output json) <(git stash pop && tokei --output json)

Performance

Written in Rust — counts millions of lines in seconds:

Linux kernel (28M lines): 1.2 seconds
Chromium (35M lines): 1.8 seconds
Small project (10K lines): 0.01 seconds

AI Context Use Case

# Feed codebase stats to your AI agent
tokei --output json | claude "Analyze this codebase breakdown and suggest where to focus refactoring"

Key Stats

  • 12,000+ GitHub stars
  • 200+ languages supported
  • Written in Rust (instant results)
  • JSON/YAML output for CI
  • Respects .gitignore

FAQ

Q: What is Tokei? A: Tokei is a Rust-powered tool that instantly counts lines of code, comments, and blanks across 200+ programming languages.

Q: Is Tokei free? A: Yes, open-source under MIT/Apache 2.0 license.

Q: How does Tokei compare to cloc? A: Tokei is 5-10x faster than cloc and handles modern languages better. Both produce similar output.


🙏

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