Line Counter

Count total, non-empty, blank and unique lines.

Free line counter — count total lines, non-empty lines, empty and blank lines, unique lines and the longest line in any text. Runs entirely in your browser, nothing is uploaded. It runs free in your browser on Gera Tools, with nothing uploaded.

Last updated Source: Gera Tools

What is the difference between empty and blank lines?

An empty line has zero characters. A blank line contains only whitespace (spaces or tabs) and may look empty but is not. The counter reports both separately.

This line counter analyses any pasted text — code, lists, CSV rows or log files — and reports six figures at once: total lines, non-empty lines, empty lines, blank (whitespace-only) lines, unique lines and the longest line length. It is handy for verifying list sizes, finding duplicates and checking line-length limits.

How it works

The tool normalises every line ending (CRLF, lone CR and LF all become a single newline) and removes one trailing newline so the count matches your editor. It then splits the text on newlines and walks each line:

MetricDefinition
Total linesNumber of lines after splitting
Non-empty linesLines with at least one non-whitespace character
Empty linesLines with zero characters
Blank linesLines containing only whitespace (includes empty)
Unique linesNumber of distinct line values
Longest lineCharacter length of the longest line

An empty line has length 0; a blank line may contain spaces or tabs and looks empty but is not, so the two are reported separately.

Worked example

Given this five-line text (one trailing newline, ignored):

First line
Second line

   
First line
MetricValue
Total lines5
Non-empty3
Empty1
Blank2
Unique4

“First line” appears twice, so unique is 4 rather than 5.

When each metric is useful

Total lines is what most people need first — verifying that a CSV export, list or config file has the expected number of rows.

Non-empty lines is the most reliable count for actual content in lists and code, because it filters both genuinely empty lines and lines that look empty but contain invisible whitespace characters.

Unique lines helps with deduplication tasks. If total is 1,000 and unique is 750, you have roughly 250 duplicate rows to investigate before importing a dataset or mailing list.

Empty vs blank is subtle but important for code style enforcement. Many linters allow a single blank separator line but forbid whitespace-only lines (which can cause diff noise). Reporting them separately lets you catch whitespace-only lines that would otherwise look clean.

Longest line is essential when you have a hard character limit — code style guides (many set 80 or 120 characters), fixed-width data formats, or email text that wraps at a given column. A quick paste tells you immediately whether any line exceeds the limit.

Common uses

  • Verifying a scraped or exported list has the expected row count
  • Checking a .env or config file for unexpected blank lines before parsing
  • Counting lines of code in a single file (use non-empty for a realistic count)
  • Spotting duplicate entries in a dataset before import
  • Checking maximum line length for code review or formatting compliance

All counting happens locally in your browser — nothing is uploaded or stored.