简体中文

Updated October 25, 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 — matching retained entries can be reused when the engine version and effective rules also match.

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?

Matching counts require the same actual source tree, tokei version, and effective counting rules, including extraction exclusions and repository attributes. A local checkout at the same commit may differ from an archive: export-ignore can omit paths and export-subst can change file contents. Record the full commit SHA, engine version, options, effective policy, and measurement date; retain the exported JSON and a saved-report link while available. Older reports may lack a complete policy. The filtering pilot measures option effects, not local-versus-server parity. See Git archive attribute semantics.

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 counts reproducible with the same source tree, tokei version, and effective filtering rules, 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. Live comparison and ref links can change as new reports are cached. Saved comparison links identify particular report IDs while those reports remain retained; export their JSON for your own records. 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. Analysis does not require 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 require GitHub account access for analysis, 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 — a matching retained result can avoid a new count. Cold-run duration depends on repository size, upstream access, queueing, and deployment limits. 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 the tool and exact version, full commit SHA, effective counting rules, and measurement date. Include a saved-report link and keep the exported JSON for a particular analysis, since saved reports are subject to retention. Repository and ref URLs are live views and must not be presented as preserved historical measurements. Older records without effective-policy metadata should disclose that limitation.

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.