Line Counter
Count lines, detect comments, and analyze your text or code
100% client-side processing
Line Statistics
| Metric | Count | Percentage |
|---|---|---|
| Total Lines | 0 | - |
| Code Lines | 0 | - |
| Comment Lines | 0 | - |
| Blank Lines | 0 | - |
| Non-Empty Lines | 0 | - |
| Max Line Length | 0 | - |
| Avg Line Length | 0 | - |
This line counter breaks any pasted text or source code into total lines, blank lines, comment lines, and real code lines, along with line-length statistics. It’s useful for developers sizing up a code file, writers checking document structure, and anyone who needs more detail than a simple word count provides.
How to Use
- Paste text: Drop your text or source code into the input area
- View counts: See total, non-empty, blank, comment, and code lines update in real time
- Check stats: Review the maximum and average line length to spot outliers
- Copy stats: Copy the full statistics table to your clipboard with one click
Features
- Total, non-empty, blank, comment, and code line counts with percentages
- Comment detection across multiple syntaxes:
//,#,--,<!--,/*, and* - Maximum and average line length analysis
- Optional whitespace trimming before counting
- Automatic CRLF/CR to LF normalization, so Windows, Mac, and Unix files count identically
- 100% client-side processing — source code never leaves your machine
What Line Counts Actually Tell You
Lines of code is one of the oldest software metrics, and one of the most misused. Raw LOC tells you roughly how big a file or project is, but it says nothing about quality: a terse, elegant function and a bloated one can do the same job in very different line counts. Using LOC to rank developer productivity is famously counterproductive — it rewards verbosity and punishes the refactoring that removes lines.
Where line breakdowns are genuinely useful is in characterizing a codebase. A high comment ratio usually signals well-documented code (or stale comments). Long maximum line lengths flag spots that may need reformatting. A sudden jump in blank-line percentage might mean sloppy generated output. This tool gives you those signals instantly, without configuring a static-analysis suite. For prose, the same counts answer practical questions: does this log file have empty rows, is my data one-record-per-line, how consistent are my line lengths?
Use Cases
- Code review: Get a quick size and comment-ratio profile of a file before diving in
- Style enforcement: Find lines that exceed a length limit, like the classic 80 or 100 columns
- Data cleaning: Verify that a dataset has no unexpected blank lines before importing it
- Writing and documentation: Check the structure of plain-text drafts, logs, or transcripts
Related Tools
Frequently Asked Questions
What counts as a comment?
Lines starting with // (JavaScript, C++, Java), # (Python, Ruby, Bash), -- (SQL, Lua), <!-- (HTML), or /* and * (CSS, multi-line comments in C-style languages) are detected as comment lines.
Does it handle mixed line endings?
Yes, the line counter automatically normalizes all line endings. It converts CRLF (Windows) and CR (old Mac) line endings to LF (Unix) before counting.
Can I count blank lines?
Yes, blank lines are counted and displayed separately in the statistics table, including both the total count and percentage.