GitHub and GitLab SLOC Counter Guide
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.
Supported Repository Hosts
| Host | Support | Entry point |
|---|---|---|
| GitHub public repositories | Web app, API, badges, Chrome extension, Firefox extension | https://github.com/owner/repo |
| GitLab public repositories | Web app and API | https://gitlab.com/group/project |
| Private repositories | Not supported | Run tokei locally instead |
How the Count Works
- OctoCounts validates the public repository URL and resolves the requested branch, tag, or commit SHA.
- The backend downloads a source archive for that exact ref instead of cloning full git history.
- The extracted source tree is counted with tokei.
- Generated and heavy dependency folders such as
.git,node_modules,target,dist, andvendorare ignored by default. - The report is cached by repository, commit SHA, tokei version, and analysis options.
Metrics Explained
| Metric | Meaning |
|---|---|
| Files | Source files detected by language rules. |
| Total lines | Code lines + comment lines + blank lines. |
| Code lines | Executable or meaningful source lines after language parsing. |
| Comments | Line and block comments recognized by the language parser. |
| Blanks | Whitespace-only lines. |
| Languages | Detected programming languages and file types, sorted by code lines. |
Examples
https://octocounts.com/?q=https://github.com/huanglizhuo/OctoCount
https://octocounts.com/github/huanglizhuo/OctoCount
https://octocounts.com/github/huanglizhuo/OctoCount/tree/main
https://octocounts.com/compare?left=https://github.com/huanglizhuo/OctoCount&right=https://github.com/tokio-rs/axum
https://octocounts.com/diff?repo=https://github.com/huanglizhuo/OctoCount&base=main&head=22c3647
Badges
Use live badges to show repository size in a README:
[](https://octocounts.com/github/huanglizhuo/OctoCount)
[](https://octocounts.com/github/huanglizhuo/OctoCount)
[](https://octocounts.com/github/huanglizhuo/OctoCount)
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 or GitLab account access, does not support private repositories, and does not accept source-code uploads. Cached reports contain public repository statistics only.