Result
All calculations run locally in your browser: parsing, chart, export. Disconnect the network and the page keeps working.
Facts and limits of this method
| Line | A text fragment between line breaks \n (or \r\n) |
|---|---|
| Empty line | A line made up only of whitespace, or with no content at all |
| Text with no line breaks | Counted as a single line |
| Empty input | 0 lines — an empty input field doesn't count as one line |
When it misleads you
- Empty text (nothing typed) counts as 0 lines, but a text of just one character with no line break already counts as 1 line — the boundary between "nothing there" and "there's one line" may not be the one your specific task expects.
- A line made up only of spaces or tabs, with no visible character, counts as "empty" — the same as a line with no characters at all.
- Different line-break conventions (\n on Unix/macOS, \r\n on Windows) are handled the same way — the line-break style doesn't affect the final count.
- A trailing line break at the end of the text (common when files are saved) doesn't add an extra empty line — only lines that genuinely exist are counted.
How it is calculated
The text is split into lines on the line-break character; the resulting array of fragments is the set of lines.
A line is considered empty if nothing is left after trimming whitespace from both ends.
The "show only non-empty lines" toggle decides which number is displayed as the large headline result — the total line count or just the non-empty ones; all three exact numbers (total, non-empty and empty) are always shown on the right regardless of the toggle.
Empty lines is the difference between the total line count and the non-empty line count.
Questions and answers
Does a line with only spaces count as empty?
Yes — if trimming the whitespace from both ends leaves nothing, the line counts as empty, even though it technically contains space characters.
Why does an empty input field show 0 lines instead of 1?
Empty text (no characters at all) doesn't produce any lines. As soon as you type at least one character with no line break, that's already 1 line.
Does a trailing line break at the end of a file increase the count?
No, the extra empty line from a trailing break isn't added — only lines that genuinely exist in the text are counted.
Is my text sent anywhere?
No, the whole count runs in your browser.