简体中文

Updated October 18, 2026 · Maintained by huanglizhuo

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

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:

How the count is produced

  1. The repository URL is validated and the requested branch, tag, or commit SHA is resolved to an exact commit.
  2. The backend downloads the compressed source archive of that commit — not the git history.
  3. The extracted tree is counted with tokei, skipping heavy dependency and build folders such as node_modules, target, dist, and vendor by default.
  4. 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

HostSupportEntry point
GitHub public repositoriesWeb app, API, report pages, badges, Chrome extension, Edge extension, Firefox extensionhttps://github.com/owner/repo
Private repositoriesNot supportedRun 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:

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:

[![OctoCounts](https://api.octocounts.com/badge/huanglizhuo/OctoCounts)](https://octocounts.com/github/huanglizhuo/OctoCounts)
[![Code lines](https://api.octocounts.com/badge/huanglizhuo/OctoCounts?type=code)](https://octocounts.com/github/huanglizhuo/OctoCounts)
[![Rust lines](https://api.octocounts.com/badge/huanglizhuo/OctoCounts?lang=Rust)](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.