Best Tools to Count Lines of Code (SLOC) in 2026
OctoCounts is a free SLOC counter for public GitHub repositories and one of six tools compared on this page. It counts files, total lines, code lines, comments, and blanks per language with tokei, run on a downloaded source archive instead of a git clone, and returns a shareable, commit-pinned report. The other tools — tokei, cloc, scc, sloccount, and GitHub's language bar — each measure size differently and suit different workflows.
Six tools compared for counting source lines of code — OctoCounts, tokei, cloc, scc, sloccount, and GitHub's built-in language bar — with what each measures, who it's best for, and where it falls short. None of these tools measure code quality; they measure size.
Comparison at a glance
| Tool | Type | Written in | Best for | Price |
|---|---|---|---|---|
| OctoCounts | Web app + browser extension | Rust / TypeScript | Public GitHub repos, no install, shareable reports | Free |
| tokei | CLI | Rust | Fast local/private counts, CI pipelines | Free, open source |
| cloc | CLI | Perl | Widest language support, legacy/unusual codebases | Free, open source |
| scc | CLI | Go | Fast counts plus complexity estimates in one pass | Free, open source |
| sloccount | CLI | Perl / C | COCOMO cost estimates on older Unix-style codebases | Free, open source (unmaintained) |
| GitHub language bar | Built into GitHub | — | A quick, no-setup glance at language mix by bytes | Free (built in) |
OctoCounts
Best for: public GitHub repos, zero install, shareable reportsOctoCounts is a free web app and browser extension that counts files, total lines, code lines, comments, and blanks for any public GitHub repository. It downloads the repository's source archive for a pinned commit instead of cloning full git history, runs tokei under the hood, and returns a permanent, shareable report URL — no local installation, no account, and no cloning required. It also ships a README badge, a GitHub Action, a CLI, and an MCP server for AI coding assistants.
tokei
Best for: fast local or private counts, CI pipelinestokei is an open-source, Rust-based command-line counter that supports over 200 languages and is one of the fastest tools in this comparison thanks to parallel file processing. It's the counting engine OctoCounts itself uses. Run it directly against any local checkout, public or private, with no network dependency.
tokei has no official web interface. OctoCounts runs tokei online, free, at commit-pinned URLs — see the tokei online guide if you want tokei's numbers for a public GitHub repository without installing anything.
cloc
Best for: the widest language and file-format supportcloc has been counting lines of code since 2006 and supports the broadest range of languages and legacy file formats of any tool here, including many niche and older languages other counters don't recognize. It's slower than tokei or scc on large codebases because it's written in Perl, but its language coverage and long track record make it the default choice when working with unusual or legacy code.
scc
Best for: fast counts plus rough complexity estimatesscc (Sloc, Cloc and Code) is a Go-based counter that's comparably fast to tokei and additionally estimates cyclomatic complexity and a COCOMO-style cost/effort figure per language. If a single command needs to produce both a line count and a rough complexity signal, scc covers both in one pass.
sloccount
Best for: COCOMO-style cost estimates on older Unix-style codebasessloccount is one of the original SLOC counters, dating to the early 2000s, known for its built-in COCOMO development-cost estimates. It's effectively unmaintained today, has weaker support for modern languages and tooling than tokei, cloc, or scc, and is included here mainly because it still surfaces in searches for SLOC history and legacy build pipelines.
GitHub's language bar
Best for: a quick, no-setup glance at language mixEvery GitHub repository page shows a colored bar breaking down the codebase by language — but that breakdown is a percentage of bytes classified by GitHub's Linguist, not a line count, and it excludes files Linguist marks as vendored, generated, or documentation. It's the fastest possible glance at what languages a repo uses, but it can't answer "how many lines" or "how much is comments versus code." See the full GitHub language bar alternative comparison.
What is the best free tool to count lines of code?
It depends on where the code lives and what you need. For a quick check of a public GitHub repository without installing anything, OctoCounts or GitHub's own language bar are fastest. For local or private codebases, tokei and scc are the fastest command-line counters, and cloc remains the most widely supported for unusual or legacy languages. There is no single best tool for every case; the right choice depends on whether the repository is public or private, whether you want a CLI or a web report, and how many languages you need recognized.
What is the difference between tokei, cloc, and scc?
All three are command-line tools that count files, code lines, comment lines, and blank lines per language. tokei and scc are written in compiled languages (Rust and Go); cloc is written in Perl. cloc has the longest track record and the widest language and file-format support, built up over two decades, while tokei and scc cover the vast majority of common languages.
Can I count lines of code without cloning a GitHub repository?
Yes. OctoCounts downloads a repository's source archive for a specific commit instead of performing a full git clone, so it transfers only the current source tree and requires no local installation. GitHub's language bar also requires no cloning, though it only reports byte-based percentages rather than line counts. Local tools such as tokei, cloc, and scc require either cloning the repository or already having a local copy to scan.
Is SLOC count a good measure of code quality?
No. Every tool in this comparison measures size, not quality, complexity, or maintainability. A larger SLOC count can mean more features, more generated or vendored code, more verbose language idioms, or simply more tests. Use SLOC counts to gauge the scale of a codebase, not to judge whether it is well written. See the counting methodology for how OctoCounts specifically defines code, comment, and blank lines.