Source Lines of Code (SLOC) Counter

"How big is this project?" Paste code and get a tokei-style breakdown: code lines, comment lines, blank lines — with a simple language picker for comment syntax.

—
Embed this tool on your website / blog No code required · Copy and paste
HTML Embed Code (iframe):
<iframe src="https://lucentool.com/code-line-counter" width="100%" height="650" style="border:1px solid #e5e0d8;border-radius:12px;max-width:850px;width:100%;" frameborder="0"></iframe>
<div style="font-size:12px;color:#78716c;margin-top:6px;font-family:sans-serif;">Powered by <a href="https://lucentool.com/code-line-counter" target="_blank" style="color:#c85a32;text-decoration:none;">Lucentool - Source Lines of Code (SLOC) Counter</a></div>

What LOC stats mean

Lines of code (LOC) is the classic project-size metric — flawed but useful for estimates, code review load and "how much did we write". The useful split is code vs comment vs blank: high comment ratio often means a complex or well-documented file; high blank ratio suggests poor structure; a huge code count in one file is a refactor signal.

How the counting works

Real-world use

Under the hood

The file is scanned line by line: newlines are normalised first, then each line is classified as blank, comment or code. Comment detection uses the prefix for the chosen language, and block comments carry a state flag across lines so their contents are not counted as code. The output separates total lines, blanks, comments and effective code lines, plus the comment ratio.

Formats, sizes and other limits

Prefix-and-state heuristics, not parsing. A // inside a string literal is counted as a comment, and template strings or regular-expression literals confuse it further. Mixed-language files — inline JavaScript or CSS inside HTML — are counted with one rule set. There is no complexity analysis and no judgement about code quality; the number is a rough size indicator, not a metric.

Privacy: nothing is uploaded

The file is counted line by line in the browser. Nothing is uploaded, which matters for proprietary source you are not free to share.

Frequently asked questions

Why is a string counted as a comment?

Because detection is prefix-based and does not parse the language. Template strings and regex literals are the usual culprits.

Which languages are covered?

Common comment prefixes: C-style, Python, shell, SQL and HTML among them. Unusual languages may need manual verification.

Does it measure complexity?

No. This counts line categories only; complexity needs a parser and a different metric.