tokei

Fast code statistics tool that counts lines of code, comments, and blanks across 150+ programming languages

install

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

add a badge to your README

Maintain tokei? Show that it's featured on trmn. The badge links back to this page.

Featured on trmn
Markdown
[![Featured on trmn](https://www.trmn.sh/badge/tokei.svg)](https://www.trmn.sh/tools/tokei?utm_source=badge)
HTML
<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>