Count total / blank / non-blank / comment / code lines instantly. Detects comments for JS, Python, SQL, HTML, CSS, Shell. Width distribution, longest line, long-line warnings.
A free line counter that breaks down any text or source file into total lines, blank lines, non-blank lines, comment lines, and pure code lines — with built-in comment detection for seven language families: JavaScript / TypeScript / Java / C / C# / Go / Rust (// + /* */), Python / Ruby / Shell (#), SQL (-- + /* */), HTML / XML (<!-- -->), CSS / SCSS, Bash / YAML / Make. View line numbers, see the width-distribution histogram, identify the longest line, and configure a "long line" threshold (default 80 chars) to flag lines that exceed your style limit. Export stats as JSON for code-quality dashboards. Everything runs in your browser — paste, drop, or upload any file. No upload, no signup.
True comment detection requires parsing the language — handling string literals that contain comment markers, escaped quotes, multi-line strings, regex literals. A line-based detector reads one line at a time without understanding the surrounding syntax. The trade-off: line-based runs in milliseconds on 100,000-line files, while a true parser is slower and language-specific.
The errors a line-based detector makes are predictable: false positives (a string containing "//" gets flagged as comment) are rare in practice. False negatives (an end-of-line comment that does not start the line) are more common. For code-quality reports, the approximate count is usually within 5% of the true count.
The width-distribution histogram shows you how lines are distributed across width buckets. Different code styles produce characteristic shapes:
For each language preset, the tool scans for the language's comment markers. Single-line markers (//, #, --) flag lines that start with that marker. Block markers (/* */, <!-- -->) flag every line from the opening marker to the closing marker. Comment-only lines count as "comment"; lines mixing code and trailing comments count as "code" because they execute. The detection is line-based — it does not parse string literals, so a line with a // inside a string will be falsely flagged. For most code-quality reports this approximation is close enough.
Source Lines Of Code = non-blank lines that are not comments. So an 800-line file with 150 blanks and 100 pure-comment lines has 550 SLOC. This matches what most LOC tools (cloc, scc, tokei) report under "code". SLOC is a poor proxy for productivity but a useful proxy for code review effort and comparing similar implementations.
Python triple-quoted strings ("""...""") are not formally comments — they are string literals that the parser ignores at the statement level. The tool treats them as code. To count docstrings as comments, copy them and paste them line by line with leading "#" markers, then re-count. For most metrics work, treating docstrings as code is the more accurate choice.
It shows how many lines fall into each character-width bucket: 0-20, 21-40, 41-60, 61-80, 81-120, 120+. A healthy code file usually has most lines in the 21-60 range with a tail to 80; a long tail above 80 suggests overly complex expressions, inline comments that should be moved, or wide string literals.
The threshold defaults to 80 characters because that is the most common style-guide limit (PEP 8, GitHub diff width). Many modern teams use 100, 120, or no limit at all. Slide the threshold to match your team's style. Lines containing tabs are counted at 1 character per tab; if your style limit is enforced post-tab-expansion, expand tabs to spaces in your editor first.
Related: line counter, count lines, lines of code counter, loc counter, sloc counter, count blank lines, count comment lines, longest line finder, line length checker, code line analyzer, text line counter, count rows in file, line width distribution, flag long lines, count comments in code