Phrasit

Search Phrasit

Search every tool, guide, and citation page.

FREE · LIVE STATS

Line counter

Count total lines, blank lines, and non-empty lines in any text. See longest, shortest, and average line length. Useful for code, logs, and lists.

0 lines

About the Line counter

The line counter splits text on line breaks and reports the total number of lines along with how many are non-empty, how many are blank, and the longest, shortest, and average line length in characters. It is built for working with structured text rather than prose: log files, CSV exports, code, lists, and anything where one record sits on one line.

A toggle lets you ignore trailing blank lines, which matters because a file that ends with a newline technically has an empty final line. Turn it on to count the way a person would, turn it off to count the way a parser would. Everything is computed locally as you paste.

How to use it

  1. Paste your text or file contents into the monospaced editor.
  2. Read the Total lines figure, then the non-empty and empty breakdown beside it.
  3. Check Longest and Shortest line length in characters to find an outlier row or a stray wrapped line.
  4. Flip Ignore trailing whitespace lines on if a final newline is inflating your count.
  5. Use Copy stats to grab the full summary as plain text for a ticket or note.

Examples

Count records in a CSV paste

You paste a CSV export and see 1,001 total lines, 1,000 non-empty. The extra line is a trailing newline after the last row. Toggle Ignore trailing whitespace lines and the total drops to 1,000, matching the 1,000 data rows you expected.

Find an over-long line

A config file should keep lines under 80 characters. The Longest stat reads 142, so one line wraps awkwardly in review. You scan for it, break the long value across two lines, and the longest drops back to 78.

Frequently asked questions

How are lines counted?
Text is split on newline characters, handling both Unix LF and Windows CRLF endings. Each split piece is one line, so a file with three lines and no trailing newline reports three, and adding a final newline makes it four unless you ignore trailing blanks.
What counts as an empty line?
A line is empty if it contains nothing but whitespace once trimmed. So a line with only spaces or tabs is counted as empty, not as a non-empty line of length two, which keeps the non-empty total meaningful for record counting.
Does the longest line length include spaces?
Yes. Longest, shortest, and average length are raw character counts including leading indentation, internal spaces, and trailing spaces. Only fully blank lines are excluded from the longest and shortest calculation.
Why does my count differ from my editor's?
Most editors number lines, so a file ending in a newline shows the same number as this tool with trailing blanks ignored. Editors that show a blank numbered line at the end match the count with the toggle off.

Good to know

Line counting is sensitive to how a file was saved. A file edited on Windows uses carriage-return plus line-feed pairs, while Unix and macOS use a bare line-feed; this tool treats both the same, but some downstream tools do not, which is a common source of off-by-one record counts. If you are reconciling a row count against a database import, ignore trailing blanks and compare against the non-empty total rather than the raw total.

For prose, line count is rarely the number you want, because a paragraph that wraps on screen is still a single line in the underlying text until you press Enter. Use the paragraph counter or word counter for essays and articles. Line counting earns its keep with lists, data dumps, and code, where each meaningful unit genuinely occupies its own line.

Related tools