GitHub SLOC Counter Guide
OctoCounts is a free SLOC counter for public GitHub repositories. Paste a repository URL, optionally pick a branch, tag, or commit SHA, and OctoCounts downloads the source archive, counts every file with tokei, and returns files, total lines, code lines, comments, blanks, and per-language totals. Reports are cached by commit SHA and can be exported as plain text, JSON, or a PNG card, or added to a README as a live badge.
OctoCounts is a free source lines of code counter for public repositories. It works from a URL, does not clone git history, and reports files, total lines, code, comments, blanks, and language totals.
What OctoCounts Is Best For
- Quickly estimate the size of an unfamiliar open source repository.
- Compare a dependency, fork, alternative project, branch, tag, or commit.
- Add a live SLOC badge to a README.
- Export language counts as text, JSON, or a social share image.
- Use an API for public repository size checks in internal tools or CI dashboards.
OctoCounts is one option among several. For head-to-head trade-offs see OctoCounts vs cloc, scc, and tokei; for a wider field including sloccount and GitHub's language bar, see the best SLOC counter tools comparison.
What does an OctoCounts report show?
A worked example: the live report for React, counted October 15, 2026 at commit 99c106c43439 with the default public configuration (tests, docs, and generated files excluded), reads: 2,132 files, 460,757 total lines — 364,991 code, 59,409 comments, 36,357 blanks — across 11 languages, JavaScript leading at 63.5% of code, with TypeScript, Rust, CSS, and the rest broken out per language in a table below the summary. Every report shows the same shape:
- Summary card: files, total lines, code, comments, blanks, and language count, with the commit SHA and tokei version it was counted at.
- Per-language table: files, total lines, code, comments, and blanks per language, sorted by code lines.
- Reproducibility block: the analysis options that produced the numbers, so a reader can rerun them (see methodology).
- Exports and next steps: text/JSON/PNG export, README badges, per-repo compare and diff links.
How the count is produced
- The repository URL is validated and the requested branch, tag, or commit SHA is resolved to an exact commit.
- The backend downloads the compressed source archive of that commit — not the git history.
- The extracted tree is counted with tokei, skipping heavy dependency and build folders such as
node_modules,target,dist, andvendorby default. - The report is cached by repository, commit SHA, tokei version, and analysis options — recounting the same commit returns the identical numbers.
The full pipeline, including how counting policy metadata and optional repository-declared filtering (.gitattributes linguist markers) work, is documented in the counting methodology.
How accurate is an OctoCounts count?
Exact for what it measures. A report is a precise count of the downloaded source archive under the stated options — same commit, same tokei version, same options on your machine returns the same numbers, because it is the same program reading the same bytes. What it is not: a measure of git history, generated artifacts excluded by the options, private code, or code quality. Two honest caveats when you quote counts: state the configuration (including or excluding tests alone can move a total by 20–50% — measured in the filtering-effects pilot study), and name the commit, since a default branch moves daily. The SLOC glossary defines each reported category precisely.
Supported Repository Hosts
| Host | Support | Entry point |
|---|---|---|
| GitHub public repositories | Web app, API, report pages, badges, Chrome extension, Edge extension, Firefox extension | https://github.com/owner/repo |
| Private repositories | Not supported | Run tokei locally instead |
tokei online, without installing anything
tokei itself has no official web interface — it is a command-line tool. OctoCounts runs tokei online, free, at commit-pinned URLs: paste a public GitHub repository URL and get the same counts the CLI would produce, pinned to an exact commit. The tokei online guide explains when an online run beats the CLI and how the two compare.
OctoCounts Docs Guides
Every guide in this section, with what each covers:
- How to count lines of code in a GitHub repository — four practical methods (web counter, browser extension, git commands, API) with exact commands and trade-offs.
- Count lines of code without cloning — archive-based counting for when a full clone is overkill.
- Can the GitHub API count lines of code? — what the API can't do, and the API routes that return real line counts.
- GitHub repository size checker — five ways to check how big a repository is before cloning, with real numbers.
- How many lines of code? The largest codebases, counted — first-party counts for linux, Firefox, LLVM, and friends, pinned to commits.
- Counting methodology — the full counting pipeline, cache key, exclusions, and citation format.
- tokei online — run tokei on public GitHub repositories without installing it.
- tokei vs cloc vs scc — the three popular open-source counters compared side by side.
- OctoCounts vs cloc, scc, and tokei — head-to-head trade-offs against the local counting tools.
- OctoCounts vs tokei — web reports vs the local CLI, same counting engine.
- OctoCounts vs scc — local complexity and COCOMO estimates vs shareable web reports.
- Best SLOC counter tools compared — six tools including sloccount and GitHub's built-in language bar.
- GitHub language bar alternative — why GitHub's byte-based language bar is not a line count.
- SLOC glossary — precise definitions of code lines, comments, blanks, and related terms.
- OctoCounts API docs — analyze endpoints, report fields, and badge routes.
- OctoCounts FAQ — answers about counting, extensions, badges, and the API.
Examples
https://octocounts.com/?q=https://github.com/huanglizhuo/OctoCounts
https://octocounts.com/github/huanglizhuo/OctoCounts
https://octocounts.com/github/huanglizhuo/OctoCounts/tree/main
https://octocounts.com/compare?left=https://github.com/huanglizhuo/OctoCounts&right=https://github.com/tokio-rs/axum
https://octocounts.com/diff?repo=https://github.com/huanglizhuo/OctoCounts&base=main&head=22c3647
Badges
Use live badges to show repository size in a README:
[](https://octocounts.com/github/huanglizhuo/OctoCounts)
[](https://octocounts.com/github/huanglizhuo/OctoCounts)
[](https://octocounts.com/github/huanglizhuo/OctoCounts)
The badges page documents every badge type and query parameter.
Comparing repositories, branches, or commits
Line counts answer "how big is this?" — comparisons answer "how big relative to what?". The compare tool puts two public repositories side by side with their language tables: a framework against its rival, a fork against upstream, or a dependency against its alternative. The diff tool tracks a single repository across refs or commits — how much a release grew, what a feature branch added. Both work from the same commit-pinned reports, so a comparison link shows the exact snapshots that were compared. There is also a curated hub of pre-built comparisons for popular pairs, from React vs Vue to Rust vs Go.
API
Programmatic users can start an analysis with POST /api/analyze, poll GET /api/jobs/:jobId, and fetch the result with GET /api/reports/:reportId. See the OctoCounts API docs for request bodies, report fields, and badge routes.
Privacy and Scope
OctoCounts analyzes public repositories only. It does not request GitHub account access, does not support private repositories, and does not accept source-code uploads. Cached reports contain public repository statistics only.
More questions about counting, extensions, badges, and the API are answered in the OctoCounts FAQ.
GitHub SLOC counter FAQ
Is OctoCounts free?
Yes. The web app, report pages, badges, API, CLI, GitHub Action, and MCP server are free to use, with no account or sign-up. OctoCounts analyzes public github.com repositories only, does not request GitHub account access, and does not accept source-code uploads.
Does OctoCounts clone the repository?
No. OctoCounts downloads the compressed source archive of the exact commit it resolves — not the full git history — which is why a first analysis usually finishes in seconds and a repeat analysis of the same commit is instant. The report records the commit SHA, the tokei version, and the analysis options it was counted with.
Which repositories can OctoCounts count?
Any public github.com repository, at a branch, tag, or commit SHA you choose. Private repositories are not supported and source uploads are not accepted; for private code, run tokei or cloc locally in your checkout.
How do I cite an OctoCounts count?
Cite tool, options, commit, and date, then link the report: for example, “torvalds/linux has 32,360,324 code lines (counted 2026-10-14 at commit 4056b3c9d3c9, tests/docs/generated excluded, via OctoCounts/tokei): octocounts.com/github/torvalds/linux”. Every report page includes a copyable citation in exactly this shape, generated from the report's own metadata.
What is the difference between code lines and total lines?
Total lines are code lines plus comment lines plus blank lines. “SLOC” usually means the code-line figure — executable or meaningful source lines after language parsing. OctoCounts reports all three categories side by side, per language and in the totals row, so any of the three definitions can be quoted from the same report.