Best CLI code counters

Compare tokei, scc, and cloc for source line counts, complexity estimates, archives, and repository reports.

Updated

short verdict

Use tokei for line counts and reusable results, scc for additional estimates and reports, or cloc for archive and revision-oriented counting.

Count a consistent set of files before comparing results. Differences in ignore rules, generated files, archive handling, and comment parsing can change the total.

this page is for

  • line counts and reusable counting results
  • line counts with complexity and cost estimates
  • code counts from archives and repository versions
#1

tokei

★ 15.1kRust
details

Use tokei for language-by-language line counts, ignore-file filtering, and a Rust library interface.

best for

  • line counts and reusable counting results

strengths

  • Respects .gitignore and .ignore with .tokeignore and --exclude options
  • Use --files for per-file counts and --input to combine earlier results
  • Export JSON, YAML, or CBOR and sort by code, comments, or blanks

weaknesses

  • Ignore rules affect the measured scope; keep them consistent before comparing repository counts.
#2

scc

★ 8.9kGo
details

Use scc when line counts need accompanying complexity estimates, unique-line counts, or an HTML report.

best for

  • line counts with complexity and cost estimates

strengths

  • Compute complexity estimates and unique lines of code
  • Skip duplicate, minified, or large files with explicit filters
  • Use --report for HTML and .sccconfig for shared settings

weaknesses

  • COCOMO cost figures depend on model assumptions; they are estimates rather than a project budget.
#3

cloc

★ 23.7k
details

Use cloc when you need line counts from source archives, selected Git revisions, or differences between versions.

best for

  • code counts from archives and repository versions

strengths

  • Separate code, comment, and blank lines by programming language
  • Process supported archive formats without manually extracting them
  • Count code at specific Git commits and compare versions

weaknesses

  • The Perl implementation requires a suitable Perl runtime for the script distribution.

How to choose

  • Choose tokei for Rust library integration or JSON, YAML, and CBOR output.
  • Choose scc for complexity estimates, unique-line counts, or an HTML report.
  • Choose cloc for archives, specific Git revisions, or differences between code versions.
  • Record exclusions and revision IDs when saving metrics for comparison.

FAQ

Do line counts measure engineering productivity?
Line counts describe the amount of source text. Treat cost or complexity estimates as separate signals, and review what files the count includes.
Which counter should I try for source archives or old Git revisions?
cloc processes supported archives without requiring manual extraction and can count code at specific Git commits. It also supports differences between versions, which suits a historical comparison.