Count lines in seconds, then tidy the list
A form only accepts 500 keywords. A class register has to match the attendance sheet. You want to know how many guests replied before you book the tables. Scrolling and counting by eye goes wrong somewhere around line 40, and a spreadsheet is a lot of effort for a quick answer.
Paste the text into the box above and the counter does the work while you type. You get the total number of lines, plus a breakdown of how many are empty, how many are repeats and how long the longest one is. If the numbers show a problem, such as gaps or the same name entered twice, the buttons under the box fix it in one click. That's why people use it as a list counter as much as a line counter.
Using the line counter, step by step
- Paste or type your text. Put one item on each line. Text copied from Excel, Google Sheets, Notepad, Word, email or a terminal window all works.
- Read the eight numbers under the box. They refresh on every keystroke, so you can watch the count change as you edit.
- Set how lines are compared. These two options only affect the unique and duplicate figures and the Remove duplicates button:
- Ignore case makes "Mumbai" and "mumbai" count as the same entry.
- Ignore spaces at line ends (on by default) stops an invisible trailing space from making two identical lines look different.
- Clean up, if you need to. Remove blank lines, remove duplicates, sort A–Z or Z–A, add numbers or trim spaces.
- Copy the result back into your document. If a button did something you didn't want, Undo restores the text from before that one change.
The eight numbers, explained
| Statistic | What it tells you |
|---|---|
| Total lines | The full line count, gaps included. |
| Non-empty lines | Lines with at least one visible character. This is usually the number of real entries in a list. |
| Blank lines | Lines that are empty or hold nothing but spaces or tabs. |
| Unique lines | How many different entries there are, counting each value once. |
| Duplicate lines | Extra copies of an entry that already appeared higher up. Remove duplicates deletes exactly this many. |
| Longest line (chars) | The length of the longest single line, which is handy when a field has a character limit. |
| Words | Groups of characters separated by spaces, tabs or line breaks. |
| Characters | Everything, including spaces, with each line break counted as one character. |
Two checks always hold: total lines equals non-empty plus blank, and non-empty equals unique plus duplicate. If a list "should" have 120 names and the non-empty figure says 124, the duplicate count tells you straight away whether repeats explain the difference.
A worked example: tidying a keyword list
Here is a short list of the kind you might export from a keyword tool or collect from a team. It has a mixed-case repeat, an empty line, and a repeat with two invisible spaces at the end of line 6:
red running shoes Red Running Shoes blue trail shoes running shoes for women blue trail shoes kids running shoes
Pasted into the counter with the default settings, it shows 7 total lines, 6 non-empty, 1 blank, 5 unique and 1 duplicate. The longest line is 23 characters ("running shoes for women"), and there are 19 words. The duplicate is the second "blue trail shoes": its trailing spaces are ignored, so it matches the first.
Tick Ignore case and the figures change to 4 unique and 2 duplicates, because "Red Running Shoes" now matches "red running shoes". Then click Remove blank lines, Remove duplicates and Sort A–Z. You are left with four clean lines:
blue trail shoes kids running shoes red running shoes running shoes for women
If you wanted "Red Running Shoes" kept instead, move it above the lowercase version before removing duplicates.
Why other programs give a different line count
If you check the same text somewhere else, you may get a number that is one higher or one lower. That is not a mistake by either program. It comes down to one question: does a line break at the very end of the text start a new line?
This counter says no. A final line break simply finishes the last line, so "a, b, c" typed on three lines is 3 lines, with or without a line break after "c". Here is how some common tools handle the same two pieces of text:
| Tool or method | a⏎b⏎c (no break at end) | a⏎b⏎c⏎ (break at end) |
|---|---|---|
| This line counter | 3 | 3 |
wc -l (Linux, macOS, Git Bash) | 2 | 3 |
Python len(text.splitlines()) | 3 | 3 |
PHP count(file($path)) | 3 | 3 |
JavaScript text.split('\n').length | 3 | 4 |
| Code editors (VS Code, Notepad++) | 3 | shows a 4th, empty line number |
wc -l counts line-break characters rather than lines, which is why it reports 2 for text without a final break. Once you know the rule, the numbers line up.
Windows (\r\n), classic Mac (\r) and Unix (\n) line breaks are all recognised, even mixed together in one paste, so a list stitched together from different sources still counts correctly.
Lines are not always records: a note on CSV files
A line counter counts lines of text. It doesn't understand file formats. In a CSV file, a cell wrapped in quotes is allowed to contain a line break, for example an address or a note. That single record then spreads over two or more lines.
For example, a CSV with a header row and two records, where one quoted note contains a line break, shows 4 lines here even though it holds only two data records. Also remember that the header row is a line too, so subtract one when you want the number of data rows. For exact record counts in complex CSV files, open them in a spreadsheet and check the row number of the last record.
What the clean-up buttons do
Remove blank lines
Deletes empty lines and lines made only of spaces or tabs. Useful for lists pasted from emails and documents, which often have a gap between every item.
Remove duplicates
Keeps the first copy of each line in its original place and drops later repeats. It follows your Ignore case and Ignore spaces settings. Blank lines are left for the button above.
Sort A–Z or Z–A
Uses natural order, so "Item 1, item 2, item 10" sort the way a person would expect instead of 1, 10, 2. Capital and small letters are treated alike, and blank lines go to the bottom.
Number the lines
Adds "1. ", "2. ", "3. " in front of each non-empty line and skips blank ones, turning a plain list into a ready-made numbered list.
Trim lines
Strips spaces and tabs from both ends of every line. Run it before importing a list into a system that treats "abc " and "abc" as different values.
Copy, Undo and Clear
Copy puts the whole result on your clipboard. Undo reverses the last button press or Clear. Rewritten text uses standard \n line breaks, which work almost everywhere.
Counting lines in other places
Sometimes the text is already inside another program. These methods give you a line count without leaving it:
- Excel or Google Sheets, lines inside one cell: a line break typed with Alt+Enter is character 10, so
=IF(A1="",0,LEN(A1)-LEN(SUBSTITUTE(A1,CHAR(10),""))+1)returns the number of lines in cell A1. - Excel or Google Sheets, one item per row:
=COUNTA(A:A)counts filled cells in column A and skips empty ones, much like the non-empty figure here. - A text file on Linux or macOS:
wc -l file.txt. Remember it reports one less if the file doesn't end with a line break. - A code editor: jump to the end of the file (Ctrl+End) and read the line number in the status bar, keeping in mind the empty last line explained above.
For a quick answer, or when you also want duplicates and blanks checked, pasting the text here is usually faster.
Where a line count is useful
- Keyword and URL lists. Many tools cap uploads at a fixed number of lines. Check the count and remove repeats before you hit the limit.
- Class lists and registers. Teachers can confirm the number of students, then pick names with the Random List Picker or split the class with the Team Generator.
- Guest lists and sign-ups. People often register twice. The duplicate count shows how many before you print name badges.
- Poems and song lyrics. A sonnet has 14 lines and a haiku has 3, so a quick count confirms the form. Blank lines between verses are counted separately.
- Log files and test data. Developers paste a slice of a log to count errors or check how many rows a script produced.
- Product codes and order numbers. Shops check a batch for repeated codes before importing it into a stock system.
Common causes of a wrong line count
- Wrapped text in a word processor. Word wraps a long sentence across several lines on screen, but it is still one line of text. The box here has word wrap turned off, so each real line stays on one row.
- Items separated by commas. "apples, pears, plums" is one line. Put each item on a new line first.
- Hidden spaces. A line containing a single space looks empty but is counted as blank, not deleted, until you use Remove blank lines or Trim lines.
- Copying from a preview. Some apps reflow text in previews and emails. Copy from the original file when the count matters.
Your text stays in your browser while you use this page: the counting and clean-up run on your own device, and nothing you paste is uploaded or saved.
Related free tools
To count words instead of lines, use the Word Counter. The Character Counter checks text against platform limits, and the Case Converter fixes capital letters across a whole list at once. Once a list is clean, you can draw a winner with the Spin Wheel. For giveaways, see our guide on picking winners fairly, and read how a random list picker makes everyday choices easier.