tokei

A fast, accurate program that counts lines of code in a project, broken down by language.

Screenshot of tokei

tokei is a fast and accurate code statistics tool. Give it a directory and it will count the number of files, lines, code lines, comments, and blank lines — broken down neatly by programming language. It's orders of magnitude faster than similar tools thanks to its parallelised architecture.

Features

  • Multi-language support — recognises over 200 programming languages
  • Blazing fast — parallelises file walking and parsing for large codebases
  • Multiple output formats — plain table (default), JSON, CBOR, YAML, and TOML
  • Sortable columns — sort results by language, code, comments, blanks, or files
  • Exclude paths — filter out directories like vendor/, node_modules/, etc.
  • Compact summary — shows a clear total row across all languages

Installation

cargo install tokei

Or via your package manager:

# Debian / Ubuntu
apt install tokei

# Fedora
dnf install tokei

# macOS
brew install tokei

# Arch Linux
pacman -S tokei

# Nix
nix-env -i tokei

Usage

# Count lines in the current directory
tokei

# Count lines in a specific directory
tokei ./src

# Output as JSON
tokei --output json

# Sort by number of code lines
tokei --sort code

# Exclude specific directories
tokei --exclude vendor --exclude node_modules

# Show only specific languages
tokei --type Rust,Python,JavaScript

Example Output

===============================================================================
 Language            Files        Lines         Code     Comments       Blanks
===============================================================================
 Rust                   42         8021         6423          782          816
 TOML                    5          198          162           12           24
 Markdown                8          612          612            0            0
-------------------------------------------------------------------------------
 Total                  55         8831         7197          794          840
===============================================================================