Line Counter

Count the lines in any text and see how long they are. As well as the total, this tool separates blank lines from real ones and reports the longest, shortest and average line length. The numbers that matter when checking data or code.

Your files never leave this device

Count your lines Live · With length statistics

0 Total lines
0 Non-empty
0 Blank lines
0 Longest line
0 Shortest line
0 Average length
0 Words
0 Characters

How to count lines

  1. Paste your text, list or code into the box above.
  2. Read the total, and check how much of it is blank lines.
  3. Look at the longest line if you are working to a width limit.
  4. Compare the average against the longest to spot outliers in the data.
  5. Clear the box when you are done. Nothing is stored anywhere.

What this counter reports

  • Total lines, counted at real line breaks rather than where the box wraps text.
  • Non-empty and blank lines separately, which matters for record counts.
  • The longest line in characters, for checking against a width limit.
  • The shortest non-empty line, which often exposes a truncated record.
  • The average line length, useful for spotting outliers.
  • Word and character totals alongside, so you do not need a second tool.

Counting lines is usually counting records

Most of the time nobody wants to know how many lines a text has for its own sake. They want to know how many email addresses are in a paste, how many rows a CSV export produced, how many entries survived a filter, or how many lines a code file runs to. The line count is a proxy for the record count, and that is why the blank-line figure matters as much as the total.

A file with 1,247 total lines and 1,198 non-empty ones has 49 blanks. If you were expecting 1,200 records, the non-empty count is the one that tells you whether anything went missing.

Where line lengths matter

  • Code style: many teams cap lines at 80, 100 or 120 characters. The longest-line figure tells you instantly whether a file complies.
  • Fixed-width data: legacy formats specify an exact width, and any line that differs is malformed.
  • Database imports: a line far longer than the average often means a field contains an unescaped delimiter.
  • Truncated records: a shortest line well below the average is usually a row that got cut off mid-write.

What counts as a line

A line ends at a genuine line break in the text, not where the box happens to wrap it visually. A long paragraph with no breaks in it is one line no matter how many rows it occupies on screen. All three line-ending conventions are handled. Windows carriage return and line feed, Unix line feed alone, and classic Mac carriage return alone, so a file from any system counts correctly.

One convention worth knowing: a file ending with a line break produces an empty final line by this counting, which is why a text file that looks like it has ten lines sometimes reports eleven. That trailing newline is standard practice in Unix tools and is the usual explanation when your count is one higher than expected.

Reading the average against the longest

The two numbers together tell you more than either alone. In well-formed data the longest line is usually within two or three times the average. When the longest is twenty times the average, something is wrong. Most often a delimiter inside a quoted field, which has caused two records to merge into one.

The same signal appears in prose. An average of 60 characters with a longest of 900 means one paragraph has no line breaks in it, which is usually a copy-and-paste artefact rather than an intentional choice.

What to do next

If the blank-line count is high and unwanted, the whitespace remover strips them in blank-line mode. If the total is higher than expected because of repeats, the duplicate line remover reports exactly how many it removes. And if the lines are the wrong length because text was hard-wrapped somewhere upstream, the line break remover reflows them properly.

Everything is counted in your browser as you type, so log files, customer data and unreleased code are never uploaded anywhere.

Frequently asked questions

Does a wrapped paragraph count as several lines?

No. Lines are counted at genuine line breaks in the text, not where the box wraps it visually. A long paragraph with no breaks is one line however many rows it fills.

Why is my count one higher than expected?

The file almost certainly ends with a line break, which produces an empty final line. That trailing newline is standard practice in Unix tools and is the usual explanation.

Are Windows and Mac line endings handled?

Yes. Carriage return with line feed, line feed alone and carriage return alone are all recognised, so files from any system count correctly.

What does a very long line usually mean?

In data, an unescaped delimiter inside a quoted field, which merges two records into one. In prose, a paragraph that lost its line breaks during copying.

Is my text uploaded to count it?

No. Everything is counted in your browser as you type, so log files, customer data and code never leave your device.