Count Lines in Text
Paste your text to count its lines instantly. The counter also shows how many lines are empty, how many are unique or repeated, and which line is the longest.
0 words 0 characters 0 lines
- Lines
- 0
- Non-empty
- 0
- Empty
- 0
- Unique
- 0
Continue with this text: Remove empty linesRemove duplicatesNumber the lines
Your text stays in your browser: nothing is uploaded or stored on a server.
How to count lines
- Paste your text into the box, type it, or click Open file to load a plain-text file (.txt, .csv, .tsv, .md, .log, .json and similar). Click Example to see a short sample first.
- Read the panel under the box. Lines is the total; Non-empty and Empty split it in two.
- Check Unique and Duplicates if you need to know whether lines repeat. Leave Ignore extra spaces when comparing lines (start, end, doubled, zero-width) ticked so that
appleandapple(with a trailing space) count as the same line, and tick Case-sensitive (Apple ≠ apple) only ifAppleandappleshould count as different lines. - Look at Longest line to see the longest line’s length in characters and its line number.
- To act on the result, use the links under the tool: Remove empty lines, Remove duplicates or Number the lines open the next tool with your text already in it.
The counts update as you type. The bar under the box also shows words, characters and lines for a quick check.
What each number means
| Number | What it counts |
|---|---|
| Lines | Every line, including empty ones. A single line break at the very end is not counted as an extra line. |
| Non-empty | Lines that contain at least one visible character. |
| Empty | Lines that are empty or contain only spaces, tabs or other whitespace. |
| Unique | Different non-empty lines. Each distinct line counts once, however often it appears; how lines are compared depends on the two checkboxes. |
| Duplicates | Extra copies: non-empty lines minus unique lines. A line that appears three times adds 2. |
| Longest line | The length of the longest line in characters, and its line number. If two lines tie, the first one is shown. |
The built-in example shows all of them at work:
apple
banana
cherry
apple
date
It gives 7 lines: 5 non-empty and 2 empty (line 3 is empty, line 6 holds three spaces), 4 unique and 1 duplicate (the second apple), and a longest line of 6 characters on line 2 (banana).
How the counter decides what a line is
A line ends at a line break. The counter accepts all three common line endings, so text from Windows (CR LF), macOS and Linux (LF) and old Mac files (CR alone) gives the same count. A long paragraph that wraps across several rows on screen is still one line: only real line breaks count, not visual wrapping. Turn wrapping off in your editor if you want to see the real lines.
The edge cases people ask about most:
| Text (↵ = line break) | Lines | Non-empty | Empty |
|---|---|---|---|
hello |
1 | 1 | 0 |
hello↵ |
1 | 1 | 0 |
hello↵↵ |
2 | 1 | 1 |
↵ (a single line break) |
1 | 0 | 1 |
Line one↵↵↵Line four↵ |
4 | 2 | 2 |
a↵(tab)↵b |
3 | 2 | 1 |
- The final line break is ignored, because most files end with one and it does not start a new line in an editor. A second break at the end does start one, and that line counts as empty. A text that is nothing but one line break counts as 1 empty line, the same as in the bar under the box.
- Whitespace-only lines (spaces, tabs, non-breaking spaces) count as empty. A line holding only an invisible zero-width space is not empty, because that character is not whitespace; the invisible character remover finds and deletes those.
- Characters in Longest line are counted as you see them: an emoji such as 👍🏽 or an accented letter counts as one character, as in the character counter.
Unique lines and duplicates
The Unique figure compares whole lines and ignores empty ones. Two checkboxes control the comparison, with the same defaults as Remove duplicate lines:
- Ignore extra spaces when comparing lines (start, end, doubled, zero-width), ticked by default: spaces at the start and end of a line are ignored, a run of spaces or tabs inside a line counts as one space, and invisible zero-width spaces are ignored.
- Case-sensitive (Apple ≠ apple), unticked by default:
Apple,appleandAPPLEare the same line. Tick it to count them separately.
Accented letters are compared after Unicode normalization, so an é typed as one character and an é built from e plus a combining accent are the same line either way.
| Lines compared | Defaults | Spaces option unticked | Case-sensitive ticked |
|---|---|---|---|
apple, apple, apple |
1 unique, 2 duplicates | 3 unique, 0 duplicates | 1 unique, 2 duplicates |
red apple, red apple |
1 unique, 1 duplicate | 2 unique, 0 duplicates | 1 unique, 1 duplicate |
Apple, apple, APPLE |
1 unique, 2 duplicates | 1 unique, 2 duplicates | 3 unique, 0 duplicates |
Because the defaults match, the counter and Remove duplicate lines agree: for the list Apple, apple, red apple, red apple, the counter shows 2 unique and 2 duplicates, and Remove duplicate lines removes those 2 lines. If you change a checkbox here, set the same one there before you click Remove duplicates.
When a line count helps
- Checking a list before importing it. A mailing list exported from a CRM or a list of product SKUs should have one entry per line. Compare Non-empty with the number of records you expect, and check Duplicates before you upload.
- Counting rows in CSV data. Paste a CSV or a column copied from a spreadsheet: every row is a line, so data rows are Lines minus the header row.
- Keyword and URL lists. SEO tools and ad platforms often take one keyword or URL per line and limit how many you can submit at once. The counter tells you whether a list fits and how many repeats you can drop.
- Poems, lyrics and scripts. Non-empty gives the number of verse lines without the blank lines between stanzas, and Longest line shows the line that may not fit on a slide or a subtitle.
- Code and logs. Paste a function or a log excerpt to count its lines; Empty shows how much of it is blank space.
Line counter vs wc -l, PowerShell and Python
If you count lines in a terminal or a script, the result can differ by one from the counter’s:
| Method | a↵b |
a↵b↵ |
How it counts |
|---|---|---|---|
| This counter | 2 | 2 | Lines; a final line break does not add a line |
wc -l (Linux, macOS) |
1 | 2 | Newline characters |
Python len(text.splitlines()) |
2 | 2 | Lines; a final line break does not add a line |
The POSIX standard defines wc -l as the number of newline characters, so a file whose last line has no line break comes out one short. Python’s str.splitlines() does not add an empty item for a final line break, which matches this counter. Python also splits at a few rarer separators, such as the Unicode line separator U+2028; this counter splits only at CR, LF and CR LF. In PowerShell, Get-Content file.txt | Measure-Object -Line counts the lines of a file; Microsoft’s documentation shows a four-line file giving 4.
To jump to a particular line in a long text, number the lines with Add line numbers, or sort the lines by length to see the longest ones together.
Questions
Does a line break at the end of the text count as a line?
No. A single final line break only ends the last line, so "hello" followed by Enter is still 1 line, as in most text editors. A second Enter starts a real empty line, so "hello" followed by two line breaks is 2 lines, one of them empty.
Are empty lines counted?
Yes. Lines includes every line, empty or not, and the panel splits it into Non-empty and Empty. A line that contains only spaces or tabs counts as empty. To delete them, use Remove empty lines.
How do I count the rows in a CSV file or a spreadsheet column?
Click Open file and choose the .csv or .tsv file, or copy the column from Excel or Google Sheets and paste it. Each row is one line, so if the file has a header row, the number of data rows is Lines minus 1.
Why does my count differ from wc -l?
wc -l counts newline characters, not lines. If the last line has no line break after it, wc -l gives one less than this counter: "a" + line break + "b" is 1 for wc -l and 2 here. When the file ends with a line break, both give the same number.
Is the duplicate count case-sensitive?
Not by default. "Apple" and "apple" count as the same line, so they give 1 unique line and 1 duplicate. Tick Case-sensitive (Apple ≠ apple) to count them as different lines. The defaults match Remove duplicate lines, so the duplicates counted here are the ones that tool removes.
Is there a limit on how much text I can paste?
There is no fixed limit; the counting runs in your browser, so the size depends on your device's memory. On very large texts the counts update after a short pause in typing instead of on every key.
Is my text uploaded anywhere?
No. The lines are counted in your browser and nothing is sent to a server. The text is kept only in this browser tab so it is still there if you open another tool.