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.
# via Source
wget https://github.com/AlDanial/cloc/releases/download/v2.08/cloc-2.08.pl && chmod +x cloc-2.08.pl