A fast command-line tool that counts files, lines, code, comments and blanks in your codebase, grouped by language.
AlDanial/cloc
cloc is a command-line tool that counts blank, comment, and source lines of code across many programming languages.
- Stars
- 23,645
- Forks
- 1,125
- Open issues
- 26
- Last commit
- 13 days ago
What is it?
cloc counts blank lines, comment lines, and physical lines of source code in many programming languages. It accepts individual files, directories, archive files such as .tar, .zip, .whl and .deb, and git commits or branches, and it can compare two versions of a codebase to report line-count differences.
It is written in Perl using only the standard Perl distribution, so the single script runs on Linux, BSD, macOS, Solaris and Windows, and a standalone Windows executable is also provided. Results can be output as plain text, Markdown, SQL, JSON, XML, YAML or CSV, and multiple runs can be summed by language or project.
It is installable through common package managers such as apt, Homebrew, npm and winget, or can be run via Docker.
Key features
- 01Counts blank, comment, and code lines across many programming languages.
- 02Reads files, directories, archives, and git commits or branches as input.
- 03Compares two code versions to show line-count differences.
- 04Exports results as text, Markdown, SQL, JSON, XML, YAML, or CSV.
- 05Runs on Perl 5.6+ without extra dependencies, and offers a Windows binary.
Use cases
- Estimating the size of a codebase before a project or migration.
- Tracking how much code changed between two git branches or releases.
- Generating line-count reports in CI pipelines using JSON or CSV output.
- Summarizing the language mix of a repository or downloaded archive.
Quick start
- 1
Install cloc via npm package manager
npm install -g cloc - 2
Open a terminal and run cloc on a directory
cloc .
Things to know
- Source version requires a Perl interpreter; Windows binary needs no requirements.
- Licensed under GPL-2.0, a copyleft license that may restrict some uses.
In collections
Topics
FAQ
- What is cloc?
- cloc is a command-line tool that counts blank, comment, and source lines of code across many programming languages. cloc counts blank lines, comment lines, and physical lines of source code in many programming languages. It accepts individual files, directories, archive files such as .tar, .zip, .whl and .deb, and git commits or branches, and it can compare two versions of a codebase to report line-count differences.
- Is cloc free to use? What license does it have?
- cloc is open source under the GPL-2.0 license. Check the license terms before using it in commercial products.
- Is cloc still maintained?
- Actively maintained. The last commit to cloc was on Oct 26, 2026.
- What can I use cloc for?
- Estimating the size of a codebase before a project or migration. Tracking how much code changed between two git branches or releases. Generating line-count reports in CI pipelines using JSON or CSV output. Summarizing the language mix of a repository or downloaded archive.
- How do I install cloc?
- Install cloc via npm package manager: npm install -g cloc Open a terminal and run cloc on a directory: cloc .
- Where can I get cloc?
- The source code and installation instructions are on GitHub: https://github.com/AlDanial/cloc
Summary generated by AI from the project's README. GitHub stats refresh daily.
Related projects
A Composer dev package for Laravel and Lumen that counts your app's code and classifies classes by Laravel component.
A CLI tool that searches, lints, and rewrites code by matching abstract syntax tree patterns instead of plain text.
AI-powered code review CLI that pairs deterministic file selection and rules with an LLM agent to leave line-level review comments on Git diffs.
A command-line tool that walks git history and tracks how complexity and code metrics of Python code change over time.
A cat(1) clone for the terminal with syntax highlighting, Git change markers, and automatic paging.