Blank Line Counter

Count the empty lines in your text, including lines with only spaces, and find the longest run of consecutive blank lines.

Blank lines

0

Total lines

0

Lines with text

0

Whitespace-only lines

0

Longest blank run

0lines

Share of lines

0%

Find the empty lines in your text

Blank lines are a formatting tool. They separate paragraphs, stanzas, sections of code and records in a file. But they also pile up by accident when text is copied from PDFs, emails, web pages and chat apps, and too many of them can break imports, inflate line counts, push content below the fold or make a document look unfinished. This blank line counter tells you exactly how many there are. Paste text above to see the number of blank lines, the total line count, how many lines contain text, how many blank lines contain hidden spaces or tabs, the longest run of consecutive blank lines, and the share of all lines that are blank.

What counts as a blank line

A line is blank if it has no visible content. That covers two cases:

  • truly empty lines, with nothing between one line break and the next;
  • whitespace-only lines, which look empty but contain spaces, tabs or other invisible whitespace.

Both are counted as blank, because both look the same on screen. But they behave differently in some tools, so the whitespace-only figure is reported separately. Code linters often flag trailing whitespace on blank lines, some diff tools show those lines as changed, and some data formats treat a line with a space as a record rather than a gap.

A final line break at the very end of the text doesn't create an extra blank line. Most text files end with one, and counting it would give an off-by-one result.

The longest run

The "Longest blank run" figure is the largest number of consecutive blank lines anywhere in the text. In most writing, one blank line between paragraphs is the norm, and two in a row can mark a section break. Runs of three, four or ten blank lines usually come from copying and pasting, and almost never look intentional. If the longest run is more than two, look for that gap and tidy it up.

Why count blank lines?

Writers and editors clean up drafts and pasted content. Text from PDFs and slide decks often has blank lines inside paragraphs, or scattered randomly. Seeing the count tells you whether a clean-up is needed before publishing.

Developers enforce style rules. Many code style guides, such as PEP 8 for Python, specify how many blank lines to use: two between top-level definitions and one between methods. Linters check for this, but a quick count helps when reviewing snippets or diffs. Blank lines with trailing whitespace are a common linter complaint, and the whitespace-only figure finds them.

Data analysts check files before import. In CSV, TSV and log files, blank lines can create empty records or cause a parser to stop early. Counting them before an import, especially the whitespace-only ones, prevents confusing errors.

Poets and lyricists check stanza breaks. In verse, a blank line separates stanzas, so the blank-line count tells you how many breaks the poem has, and the longest run confirms there are no accidental double gaps.

Email and form writers keep messages tidy. A long run of blank lines at the end of an email or a form submission is easy to miss and looks sloppy to the recipient.

How to remove blank lines

If you need to remove blank lines, there are several easy routes:

  • The full Word Counter has a one-click "remove empty lines" clean-up, which strips blank and whitespace-only lines from the whole text or a selection.
  • Most code editors can do it with a regular-expression find and replace: search for ^\s*$\n and replace with nothing.
  • In a word processor, find and replace two paragraph marks with one, repeating until none are found.

If you want to keep paragraph breaks but remove extra gaps, replace runs of blank lines with a single blank line rather than removing them all.

Blank lines and paragraph counts

Paragraph counters use blank lines to tell where one paragraph ends and the next begins. If your paragraph count looks wrong, check the blank lines first. Too few and paragraphs merge, too many inside a paragraph and it splits. The Paragraph Counter treats any run of blank lines as one break, so extra gaps don't add paragraphs, but missing ones do merge them.

Blank lines in Markdown and HTML

In Markdown, blank lines carry meaning. A single line break inside a paragraph is usually ignored when the text is rendered, and a blank line starts a new paragraph. Lists, code blocks and headings often need a blank line before them to render correctly. So a Markdown file with too few blank lines can display as one long paragraph, while extra blank lines between paragraphs usually make no visible difference at all, because consecutive blank lines collapse into one.

HTML ignores blank lines completely. Whitespace between tags collapses into a single space when the page is displayed. Blank lines in HTML source are purely for the benefit of people reading the code.

Plain-text email is different again. Every blank line is shown exactly as typed, so a message with four blank lines between paragraphs will display with large gaps. That's one reason pasted text can look fine in one place and badly spaced in another. When you're preparing text for a specific destination, check how that destination treats blank lines, then use the counter to make sure your text matches.

Related tools

For a complete line breakdown, including the longest line and average line length, use the Line Counter. To find spaces, tabs and other whitespace inside lines, the Space Counter gives the detail. All of these work in your browser, and nothing you paste is uploaded.

How to use it

  1. 1

    Paste your text

    Text, code, a CSV file or anything with line breaks.

  2. 2

    Read the blank-line count

    Empty lines and whitespace-only lines are both counted.

  3. 3

    Check hidden whitespace

    See how many blank-looking lines contain spaces or tabs.

  4. 4

    Find the longest gap

    The longest run shows the biggest stretch of consecutive blank lines.

Features

Hidden whitespace

Whitespace-only lines are counted and reported separately.

Longest run

Finds the biggest gap of consecutive blank lines.

Accurate line totals

A trailing newline doesn't add a phantom line.

Private

Text and data stay on your device.

Domande frequenti

Does a line with only spaces count as blank?

Yes. It's included in the blank-line count and also reported in the whitespace-only figure.

Does the final line break count?

No. A trailing newline at the end of the text doesn't create an extra blank line.

How do I remove blank lines?

Use the remove empty lines option in the Word Counter, or a find and replace in your editor.

How many blank lines should be between paragraphs?

One is standard. Two can mark a section break. More is usually accidental.

Can I use this for code?

Yes. It's useful for checking style rules on blank lines and finding trailing whitespace.

Is my text uploaded?

No. Everything is counted in your browser.

Rate Blank Line Counter

No account needed, and ratings are anonymous.

How useful was this tool?
No ratings yet — be the first

Further reading

All articles →