cloc
Command-line tool that counts blank, comment, and source code lines across many programming languages.
cloc is a cross-platform code analysis tool that counts lines of code across many programming languages. It separates blank lines, comment lines, and physical source code lines, providing detailed statistics for individual files, directories, archives, and git repositories. The tool recognizes dozens of programming languages and can process various file formats including compressed archives, Python wheels, Jupyter notebooks, and package files.
Written entirely in Perl with no external dependencies beyond Perl v5.6, cloc runs on Linux, macOS, Windows, and various Unix systems. It can analyze code in archive formats like .tar, .zip, .rpm, and .deb files without requiring extraction. The tool supports git integration, allowing users to count code at specific commits or across repository history.
cloc is particularly useful for software metrics, project analysis, and code reviews. It provides summary statistics and can compute differences between code versions. The tool handles both individual file analysis and bulk processing of directory structures, making it suitable for projects of any size. Output includes file counts, language breakdowns, and totals for blank lines, comments, and executable code.
Installation
# via Source
wget https://github.com/AlDanial/cloc/releases/download/v2.08/cloc-2.08.pl && chmod +x cloc-2.08.pl
Alternatives & related tools
sops
Editor for encrypted files supporting YAML, JSON, ENV, INI formats with AWS KMS, GCP KMS, Azure Key Vault, age, and PGP encryption
radare2
Command-line reverse engineering framework for disassembling, analyzing, emulating, debugging and patching binaries across many architectures and file formats.
asdf
Version manager that handles multiple language runtimes per project through plugins, using a single CLI and a .tool-versions file.
VHS
Generate terminal GIFs from code scripts for testing and demonstrating CLI tools
difftastic
Structural diff tool that compares files based on their syntax rather than lines
add a badge to your README
Maintain cloc? Show that it's featured on trmn. The badge links back to this page.
[](https://www.trmn.sh/tools/cloc?utm_source=badge)<a href="https://www.trmn.sh/tools/cloc?utm_source=badge"><img src="https://www.trmn.sh/badge/cloc.svg" alt="Featured on trmn" height="20"></a>