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.
Instalación con revisión previa
Este activo requiere revisión. El prompt copiado pide dry-run, muestra escrituras y continúa solo tras confirmación.
npx -y tokrepo@latest install e18416ca-e46b-4db6-b955-f485db46c8ed --target codexPrimero dry-run, confirma las escrituras y luego ejecuta este comando.
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
Preguntas frecuentes
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.
Referencias (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
Relacionados en TokRepo
Fuente y agradecimientos
Created by XAMPPRocky. Licensed under MIT/Apache 2.0.
tokei — ⭐ 12,000+
Thanks for making codebase statistics instant.
Discusión
Activos relacionados
pbi-cli — Power BI Skills for Claude Code
pbi-cli is a Python CLI that installs Claude Code skills for Power BI models and PBIR reports. Get started with pipx + `skills install`.
D2 — Declarative Diagram Scripting Language
A modern diagram scripting language that turns text into diagrams, offering a readable syntax for architecture, flow, and sequence diagrams rendered from code.
RSSHub — Universal RSS Feed Generator for Any Website
Self-hosted RSS feed generator that creates RSS feeds from virtually any website, supporting hundreds of sources including social media, news, and developer platforms.
Hexo — Fast Node.js Blog Framework with Plugin Ecosystem
Hexo is a fast, simple, and extensible blog framework powered by Node.js. It renders Markdown posts into static HTML in seconds and supports hundreds of themes and plugins.