Line Counter
Count lines in your text, with separate counts for blank and non-blank lines. Browser-only.
Total lines
0
Non-blank lines
-1
Blank lines
1
Longest line
0
characters
About Line Counter
The line counter splits your text on line breaks (LF or CRLF) and reports the total number of lines, plus how many are blank and how many contain content. It's the tool of choice for measuring code length, log size, list length, and similar.
When to use it
- Measuring lines of code in a snippet
- Counting rows in a CSV before processing
- Verifying that a list has the expected number of items
- Checking the size of a log slice
How it works
The input is split on /\r?\n/, accepting both Unix (LF) and Windows (CRLF) line endings. An empty input produces zero lines; a single character (or any content) produces at least one line. Blank lines are those whose content trims to an empty string.
Examples
line 1 line 2 line 4
4 lines (3 non-blank, 1 blank)
Frequently asked questions
- What line endings are supported?
- LF (\n) and CRLF (\r\n) are both treated as line separators. Mixed line endings in one input are handled correctly.
- Does a final newline create an extra line?
- Yes. 'hello\n' counts as 2 lines (the content and the empty trailing line). This matches how `wc -l` differs from a 'logical' line count.
- How is a blank line defined?
- A line whose contents (after stripping whitespace) is empty. Lines with only spaces or tabs count as blank.