tokei
Fast code statistics tool that counts lines of code, comments, and blanks across 150+ programming languages
Tokei is a command-line code analysis tool that generates detailed statistics about codebases. It counts files, total lines, code lines, comments, and blank lines, organizing results by programming language. The tool supports over 150 languages and their file extensions, correctly handling multi-line comments, nested comments, and comments within strings for accurate analysis.
The tool excels at performance, processing millions of lines of code in seconds. It respects .gitignore and .ignore files by default, with additional filtering options through --exclude flags and .tokeignore files. Results can be sorted by various metrics (files, lines, code, comments, blanks) and output in multiple formats including JSON, YAML, and CBOR for integration with other tools.
Tokei offers flexible usage patterns, from basic directory analysis (tokei ./src) to complex workflows involving multiple directories, custom exclusions, and format transformations. The --files flag provides per-file statistics, while the --input option allows combining results from previous runs. It functions both as a standalone CLI tool and as a Rust library for programmatic integration.
Installation
# via Homebrew
brew install tokei
# via Cargo
cargo install tokei
# via Package Manager
pacman -S tokei
Alternatives & related tools
asciinema
Command-line tool for recording and live streaming terminal sessions to lightweight asciicast files
Hurl
Command line tool that runs and tests HTTP requests defined in plain text files, with request chaining, captures, asserts, and CI reports.
hexyl
Terminal hex viewer that colors bytes by category: NULL, printable ASCII, whitespace, other ASCII, and non-ASCII.
grex
CLI tool that generates regular expressions from user-provided test cases automatically
tailspin
Log file highlighter (binary: tspin) that colors dates, numbers, IPs, UUIDs, URLs and more in any log format, with no config, and pages output through less.
add a badge to your README
Maintain tokei? Show that it's featured on trmn. The badge links back to this page.
[](https://www.trmn.sh/tools/tokei?utm_source=badge)<a href="https://www.trmn.sh/tools/tokei?utm_source=badge"><img src="https://www.trmn.sh/badge/tokei.svg" alt="Featured on trmn" height="20"></a>