Use the form above. Parameters, code examples and FAQ are grouped in the documentation section below.

Free GitHub LOC counter: count lines of code (LOC) of any GitHub or GitLab repository by programming language — files, blanks, comments and code share. No signup, no install, with a free LOC API.

Description
- Tool for counting lines of code from github/gitlab repositories.
- Max repo size: 300 MB (compressed) / 1.5 GB uncompressed, 200k files. Bigger repos will not work.
- Default branch is auto-detected; pick another one with the branch box or &branch=name.
- Ignore files or directories by writing them comma-separated in the ignore box.
- Click a legend entry to hide that language; the table totals update to match.
- Click a pie slice to recolor it. Colours follow the GitHub linguist palette.
- Recognises ~35 languages; vendor, dist, build, target, *.min.js and binary files are skipped.

- Limit : 30 requests per minute. Once reached subsequent requests will result in error 429 (too many requests) until your quota is cleared.
LOC counter FAQ
How do I count lines of code of a GitHub repo?
Select GitHub, type user/repo and press ADD. You get per-language files, lines, blanks, comments and lines of code with percentages.
Can I count LOC of a single file?
The tool counts whole repositories (it downloads the repo archive). For a single file, use the per-language table to find its language share, or the /v1/loc API and filter the JSON.
Is there a LOC API?
Yes: /v1/loc?github=user/repo returns JSON per language, with an optional branch parameter.

Endpoint - Get Lines of Code from GitHub repo
This endpoint retrieves LOC from any github repo based on programming language.
HTTP Request:
curl /v1/loc?github=username/reponame
HTTP Request:
GET /v1/loc?github=username/reponame
GET /v1/loc?gitlab=username/reponame
Select branch
If you want a branch other than the repository default
/v1/loc?SOURCE=USERNAME/REPONAME&branch=branchName
Ignore files or directories
Can ignore files or directories using param ignored
/v1/loc?SOURCE=USERNAME/REPONAME&ignored=DIRNAME1,DIRNAME2,FILENAME
example :
/v1/loc?github=cli/cli
/v1/loc?gitlab=gitlab-org/gitlab-runner
/v1/loc?github=ImageMagick/ImageMagick&branch=main
/v1/loc?github=cli/cli&ignored=docs,website
Detail mode (file explorer + file types):
Add detail=1 to also get every file and a per-extension breakdown.
/v1/loc?github=username/reponame&detail=1
response :
  [{
    "language": "JavaScript",
    "files": 1,
    "lines": 176,
    "blanks": 14,
    "comments": 6,
    "linesOfCode": 156
  },   
  ... more languages
  {
    "language": "Total",
    "files": 8,
    "lines": 921,
    "blanks": 148,
    "comments": 46,
    "linesOfCode": 743
  }] 
        


Documentation & API reference

How to use the Count LOC

Count lines of code in any public GitHub or GitLab repository, broken down by language, plus per-file and per-extension detail.

Endpoints

EndpointReturnsExample
/v1/locJSONgithub=torvalds/linux

Parameters

NameTypeDefaultDescription
githubstringrequiredRepository as user/repo. Use gitlab for GitLab instead.
gitlabstringrequiredRepository as group[/subgroup]/repo. Use github for GitHub instead.
branchstringautoBranch to count. Defaults to the repository default branch.
ignoredstring-Comma-separated files or directories to exclude, e.g. vendor,dist,*.snap.
detailstring-Set to 1 to also return extensions[] and files[].

Code examples

curl 'https://freetools.one/v1/loc?github=torvalds/linux'
const stats = await (await fetch('https://freetools.one/v1/loc?github=cli/cli')).json();
const total = stats.find(l => l.language === 'Total');
console.log(total.linesOfCode, 'LOC in', total.files, 'files');
import requests

stats = requests.get('https://freetools.one/v1/loc',
                   params={'github': 'cli/cli'}).json()
total = [s for s in stats if s['language'] == 'Total'][0]
print(total['linesOfCode'], 'LOC in', total['files'], 'files')

Example response

[
  {
    "language": "Rust",
    "files": 300,
    "lines": 40000,
    "blanks": 3000,
    "comments": 2000,
    "linesOfCode": 35000,
    "percent": 91.9
  },
  {
    "language": "Total",
    "files": 512,
    "lines": 43500,
    "blanks": 3200,
    "comments": 2300,
    "linesOfCode": 38000,
    "percent": 100.0
  }
]

Frequently asked questions

How do I count lines of code of a GitHub repository?

Call /v1/loc?github=user/repo. The response breaks the repository down by language and reports files, lines, blanks, comments and lines of code for each one.

Can I count the lines of code of a single file?

The tool counts whole repositories because it works from the source archive. For one file, request detail=1 and filter the files[] array by path, or use ignored= to exclude everything else.

Which files are skipped automatically?

vendor, dist, build, target, out, node_modules, .next, coverage, venv and .venv directories, generated bundles such as *.min.js, and any file containing binary data.

How large a repository can it handle?

Up to 300 MB compressed and 1.5 GB uncompressed, with a ceiling of 200,000 files. Larger archives are rejected with HTTP 413 rather than timing out.