๐Ÿ“—Lines of Code (LOC) Counter

Count code, comment and blank lines separately

LineKindContent (first 40 chars)

Quotes are tracked so a comment marker inside a string is not mistaken for a comment. Template literal interpolation, regular expression literals, heredocs, raw strings and nested block comments are not implemented, so treat the figures as indicative when code leans on those. A blank line counts as blank even inside a block comment.

You Might Also Need

How to use the lines of code counter

Paste your code, choose a comment syntax, and the page splits the input into total lines, blank lines, comment-only lines, lines carrying both code and a comment, and plain code lines. Source lines of code is the sum of plain code lines and mixed lines. The table shows how the first forty lines were classified, so you can see exactly why a number came out the way it did.

How the counting works

Each line is read character by character while the quote and block-comment states carry across lines. A comment marker inside a string is not treated as a comment, and a block comment keeps its state over as many lines as it spans. The syntax you selected is printed with the results so the rule in force is never implicit. Blank lines count as blank even inside a block comment, which follows common practice. As of October 2026.

Limits worth knowing

Only the comment syntaxes in the list are recognized, and no other language is guessed at. Template literal interpolation, regular expression literals, heredocs, raw strings and nested block comments are not implemented, so classification can drift on code that uses them heavily. Because no authoritative standard exists for comment share or lines per language, the ratios carry no judgment. Everything is processed in your browser.

Frequently Asked Questions

Does a // inside a string get counted as a comment?

No. Quotes are tracked, so a string such as "https://example.com" counts as code. Template literal interpolation and regular expression literals are not implemented, so if your code leans on those, spot-check a few rows in the classification table.

What comment share should I aim for?

There is no authoritative figure for the right comment share in any language. That is why this page reports the ratio and attaches no verdict. If you need a comparison, measure other files in the same repository.

What does this tool not do?

It does not estimate effort or cost, and it does not score complexity. There is no file upload or repository-wide total either; it classifies the lines you paste and stops there.