Line Counter

Count lines in a text: every line, lines with content, completely empty lines and lines that contain only spaces or tabs.

Result

All lines
0
Non-empty lines
0
Empty lines
0
Whitespace-only lines
0
Longest line (characters)
0

Processed in your browser. Nothing you type is uploaded.

How it works

Windows (\r\n), Unix (\n) and old Mac (\r) line endings are all recognised and treated the same. The text is then split at each line break and each line is classified.

Rules this tool follows

  • All lines counts every line, like the line numbers in a text editor. Empty input has zero lines.
  • A line break at the very end of the text creates a final empty line, just as it does in an editor.
  • Non-empty lines contain at least one visible character.
  • Whitespace-only lines contain spaces or tabs but nothing visible; they look empty but are not.
  • Longest line is measured in characters.

Example

Input

apple

   
banana

Output

All lines: 5
Non-empty lines: 2
Empty lines: 2
Whitespace-only lines: 1

Common uses

  • Counting items in a list, one per line.
  • Checking rows in a CSV or log file before importing it.
  • Finding invisible whitespace-only lines that break scripts or imports.

Limitations and notes

  • Lines are counted as stored, not as they wrap on screen. A long paragraph that wraps visually is still one line.

All text counters