explaingit

aldanial/cloc

📈 Trending23,054PerlAudience · developerComplexity · 1/5ActiveLicenseSetup · easy

TLDR

Command-line tool that counts lines of code in a project, breaking down totals by language and separating code, comments, and blank lines.

Mindmap

mindmap
  root((cloc))
    What it does
      Counts lines of code
      Separates code comments blanks
      Supports hundreds languages
    How to use it
      Scan directories
      Analyze git commits
      Process zip archives
    Use cases
      Estimate project size
      Onboard to codebases
      Generate metrics reports
    Tech stack
      Perl
      Command-line interface
    Outputs
      Summary tables
      Per-language breakdown
      File counts

Things people build with this

USE CASE 1

Onboard to an unfamiliar codebase by quickly understanding its size and language composition.

USE CASE 2

Estimate effort and timeline for a rewrite or refactoring project by measuring total lines of code.

USE CASE 3

Generate metrics reports showing code volume, comment coverage, and language distribution for stakeholders.

USE CASE 4

Analyze git commits to track how much code was added or removed in a specific change.

Tech stack

Perl

Getting it running

Difficulty · easy Time to first run · 5min
Use freely for any purpose, including commercial use, as long as you keep the copyright notice.

In plain English

cloc (Count Lines of Code) is a command-line tool that counts how many lines of source code are in a project. It breaks down the count by programming language and separates actual code lines, comment lines, and blank lines, giving you a clearer picture than a simple total. The problem it solves is simple but useful: when you inherit a codebase, want to estimate its size for a project plan, or need to report on how large a software system is, manually counting is impractical. cloc scans a file, directory, zip archive, or even a specific git commit and produces a neat summary table showing file counts and line counts per language. You would use this when onboarding to an unfamiliar project and want to understand its scale and composition, when estimating effort for a rewrite, or when generating metrics for reporting. It supports hundreds of programming languages and can be run on Windows, macOS, and Linux. It requires a Perl interpreter when running the source version, but Windows users can use a standalone executable with no dependencies. cloc is written in Perl and is a single-file command-line program.

Copy-paste prompts

Prompt 1
How do I use cloc to count lines of code in my project directory and see a breakdown by programming language?
Prompt 2
Show me how to run cloc on a specific git commit to see how many lines were added or removed.
Prompt 3
I want to analyze a zip archive with cloc and export the results as a CSV file for reporting. What's the command?
Prompt 4
How can I use cloc to compare code volume across multiple projects or directories?
Prompt 5
What does cloc count as 'code' vs 'comments' vs 'blank lines', and how do I interpret the output table?
Open on GitHub → Explain another repo

Generated 2026-05-18 · Model: sonnet-4-6 · Verify against the repo before relying on details.