Repolode
AlDanial

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. 1

    Install cloc via npm package manager

    npm install -g cloc
  2. 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

#code-metrics#command-line#perl#lines-of-code#git#static-analysis#cloc#count-lines#programming-language

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