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.
# via Homebrew
brew install tokei
# via Cargo
cargo install tokei
# via Package Manager
pacman -S tokei