Count lines

Total, non-empty, empty and unique line counts.

Press the button and you get four numbers: the total number of lines, how many contain something, how many are blank, and how many are distinct.

Four numbers, not one

"How many lines" almost always means one of the other three, and which one matters.

Total lines is what an editor shows in its gutter. Use it when you need to match what someone else is looking at, or to check a file has the number of rows a system expects.

Non-empty lines is the real content count. If your text came from a PDF or a web page, the total is inflated by blank lines and only this number reflects how many items you actually have.

Unique lines is the one people forget to check and the one that most often reveals a problem. Import 5,000 email addresses, see 4,200 unique, and you have found 800 duplicates before they became 800 duplicate records. Any gap between non-empty and unique is worth understanding before you proceed.

Empty lines is the difference, and it tells you how much cleanup the text needs.

How lines are counted

All three line ending conventions are handled — Unix, Windows and old Mac — so text that has passed through different systems counts correctly rather than coming out as one line or double the real number. That failure is common in tools that split on a single newline character only.

Uniqueness is compared after trimming, since a line with a trailing space is the same item as one without and counting them separately hides duplicates rather than revealing them. If a trailing newline leaves you one line short of what an editor reports, that is why: an editor counts the empty final line, a counter usually does not.

Uses

For counts inside each line rather than of the lines themselves, use the per-line counter, which gives characters and words for every line and flags any over a limit.

Doing it without this tool

Excel: =COUNTA(A:A) for non-empty cells, =SUMPRODUCT(1/COUNTIF(A1:A100,A1:A100)) for unique values — a formula almost nobody writes from memory.

Notepad++ and VS Code: both show the current line number in the status bar, so Ctrl+End gives you the total. Neither tells you how many are unique.

Command line: wc -l file.txt for the total, grep -c . for non-empty, sort -u file.txt | wc -l for unique.

Try:
0Words
0Characters
0No spaces
0Sentences
0Paragraphs
0Lines
0Pages
0Reading
0Speaking

Runs entirely in your browser. Your text is never uploaded — open DevTools, Network tab, and you will see zero requests while you use this tool.

How to use it

  1. Paste your text into the box.
  2. Press "Count lines".
  3. Compare non-empty against unique — a gap means duplicates.
  4. Use the cleanup buttons if the counts show blank lines or repeats.

Related tools

Character counterLive character count with and without spaces, plus common platform limits.X / Twitter counterCounts your post against the 280 character limit on X, plus name and bio limits.Word counterCounts words, characters, sentences and reading time while you type.Sentence counterCounts sentences and paragraphs, and shows your average sentence length.Username generatorReadable names built from real words. No xX_ padding, no forced digits.Upside down textFlip a line so it reads the other way up. Copy and paste anywhere.Title case vs sentence caseThree style guides, three different answers, and the four-letter rule that…

See all text tools →

Frequently asked questions

What is the difference between total and non-empty lines?

The total includes blank lines, which is what an editor shows in its gutter. Non-empty counts only lines with content, which is the real number of items when your text came from a PDF or a web page.

Why does my editor show one more line than this?

Because a file usually ends with a newline, and an editor counts the empty line after it. A counter treats that as the end of the last line rather than a new one.

How does it count unique lines?

Lines are compared after trimming whitespace, so an item with a trailing space is not counted as a separate one. A gap between non-empty and unique is exactly the number of duplicates.

Does it handle Windows and Mac line endings?

Yes, all three conventions are recognised. Tools that split on a single newline character give wrong counts on files that came from another system.

Can I count characters or words per line as well?

Yes, the per-line counter tool gives characters and words for every line and can flag lines over a limit you set.