DEVELOPER & DATA

Code Line Counter

Count lines of code the cloc way — code, comment-only and blank lines — plus bytes, longest line, indentation style, trailing whitespace and line endings.

A summary block with the line split (code / comment / blank), comment blocks, size, longest and average line, indentation, trailing whitespace and line-ending facts.

Example: A 10-line JS snippet → 5 code (1 with a trailing comment), 4 comment, 1 blank; "http://x.com" inside a string is not a comment; 2-space indentation; LF with a final newline.

v0.1.0 · last reviewed 21 September 2026
Loading the workspace…
BUILT TO BE UNDERSTOOD

Code, comment,
blank.

The cloc convention, the comment scanner, and the style facts.

The three buckets

A line is blank when it has only whitespace, a comment line when everything on it outside whitespace is inside a comment, and a code line otherwise — including a line of code with a trailing comment, which cloc also counts as code. The counts add up to the total, and the number of trailing-comment lines is shown separately.

The scanner

Comments are found by a small state machine per family: C-like (// and /* */), CSS (/* */), hash (# to end of line), SQL (-- and /* */), HTML (<!-- -->) and Lua. It walks string literals so that “http://x” inside quotes is not a comment. The family is detected from the text (tags, SQL keywords, Python keywords, CSS blocks) and can be overridden. Regex literals in JavaScript are not parsed, so a regex containing quotes or a double slash can mislead the count.

Style facts

Characters exclude line breaks; the size is UTF-8 bytes of the whole text. Indentation is judged on code lines only: tabs, spaces or mixed, with the common width as the greatest common divisor of the indents. Trailing whitespace, line-ending style (LF, CRLF or mixed) and the final newline are reported because they are what linters complain about. Nothing leaves the browser; the same four anonymous usage counts as the rest of the site apply.

SOURCES

  • Comment families: C-like (// and /* */), CSS, hash (#), SQL (-- and /* */), HTML (<!-- -->), Lua; string literals skipped; a line with code and a comment counts as code, as in cloc

Last reviewed 21 September 2026. How results are checked: How we verify.