# cloc

> Command-line tool that counts blank, comment, and source code lines across many programming languages.

Stars: 23.6k · Categories: Dev Tools

- Repository: https://github.com/AlDanial/cloc
- Page: https://www.trmn.sh/tools/cloc

## Install

- Source: `wget https://github.com/AlDanial/cloc/releases/download/v2.08/cloc-2.08.pl && chmod +x cloc-2.08.pl`

## Overview

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

```bash
# via Source
wget https://github.com/AlDanial/cloc/releases/download/v2.08/cloc-2.08.pl && chmod +x cloc-2.08.pl
```

## Alternatives

- [sops](https://www.trmn.sh/tools/sops.md): Editor for encrypted files supporting YAML, JSON, ENV, INI formats with AWS KMS, GCP KMS, Azure Key Vault, age, and PGP encryption (Go, 23.6k stars)
- [radare2](https://www.trmn.sh/tools/radare2.md): Command-line reverse engineering framework for disassembling, analyzing, emulating, debugging and patching binaries across many architectures and file formats. (C, 25.3k stars)
- [asdf](https://www.trmn.sh/tools/asdf.md): Version manager that handles multiple language runtimes per project through plugins, using a single CLI and a .tool-versions file. (Go, 25.6k stars)
- [VHS](https://www.trmn.sh/tools/vhs.md): Generate terminal GIFs from code scripts for testing and demonstrating CLI tools (Go, 21.2k stars)
- [difftastic](https://www.trmn.sh/tools/difftastic.md): Structural diff tool that compares files based on their syntax rather than lines (Rust, 26.1k stars)

---

Canonical: https://www.trmn.sh/tools/cloc
