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
- Checking an import file has the expected number of rows before uploading.
- Finding duplicates by comparing unique against non-empty.
- Reconciling two exports that should contain the same number of records.
- Sizing a job — how many URLs to check, addresses to write to, items to process.
- Verifying a cleanup worked, by counting before and after.
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.
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
- Paste your text into the box.
- Press "Count lines".
- Compare non-empty against unique — a gap means duplicates.
- Use the cleanup buttons if the counts show blank lines or repeats.
Related tools
Frequently asked questions
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.
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.
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.
Yes, all three conventions are recognised. Tools that split on a single newline character give wrong counts on files that came from another system.
Yes, the per-line counter tool gives characters and words for every line and can flag lines over a limit you set.