tokei
Count lines of code by language
TLDR
Display a report for the code in a directory and all subdirectories
Display a report for a directory excluding .min.js files
Display statistics for individual files in a directory
Display a report for all files of type Rust and Markdown
SYNOPSIS
tokei [OPTIONS] [PATH...]
PARAMETERS
--help
Display help information.
--version
Display version information.
-l, --languages
List supported languages.
-o, --output
Output in a specific format (e.g., json, toml, yaml, compact, csv, short).
-f, --files
Restrict file types to analyze, specified as a comma-separated list (e.g., rs,cpp).
-e, --exclude
Exclude paths from analysis. Can specify multiple paths.
-i, --ignore
Exclude files based on .ignore or .gitignore. Can specify multiple files.
-n, --no-ignore
Do not use ignore files
-d, --disable
Disable specified language(s).
-c, --categories
Filter Languages by category (markup,procedural...).
PATH...
Paths to analyze. Defaults to the current directory if none is specified.
DESCRIPTION
Tokei is a program that counts lines of code. Unlike simple line counters, Tokei recognizes different types of files, ignores blank lines, and provides a breakdown of the codebase by language. It's designed to be accurate and efficient, offering more insights than just raw line counts. Tokei supports a wide array of programming languages. It's especially useful for projects where understanding the distribution of code across different languages is important, for tracking project size and complexity, or for auditing codebases.
Tokei works by examining file extensions and content to determine the programming language. It then parses the file, identifying code lines, blank lines, and comments. The results are presented in a clear, organized format, showing the number of files, lines of code, blank lines, and comment lines for each language. Tokei is cross-platform and can be used on Linux, macOS, and Windows.
CAVEATS
Tokei relies on file extensions for language detection, which might not always be accurate. For complex or ambiguous projects, results may need verification. Incorrectly configured ignore files can lead to inaccurate results.
OUTPUT FORMATS
Tokei can output data in various formats, including JSON, TOML, YAML, CSV, compact and short. This allows for easy integration with other tools and scripts for further analysis and reporting.
PERFORMANCE
Tokei is generally fast, but performance can degrade on very large codebases with many files. Excluding irrelevant directories or using the file type filter can improve performance.
HISTORY
Tokei is a relatively newer tool compared to traditional line counting utilities. It was developed to provide more accurate and insightful code statistics by recognizing different programming languages and filtering out comments and blank lines. It's gained popularity in recent years as a more sophisticated alternative to simple line counting tools.