textscrubr
Home / Blog / Punctuation

How to Remove Extra Blank Lines From Text

Punctuation2 min readUpdated 2026-06-24
To remove extra blank lines, paste your text into a cleaner that collapses three or more line breaks into a single blank line, or use find-and-replace with a regex like \n{3,} replaced by \n\n. This tidies vertical spacing while keeping one clean break between paragraphs.

Text copied from documents, PDFs, and chatbots often arrives with big vertical gaps, multiple blank lines stacked between paragraphs. Here is how to tidy them.

What causes extra blank lines

Sources add vertical spacing in different ways. When you copy and paste, those extra line breaks come along, so you end up with two, three, or more blank lines where one would do. It makes the text look sparse and unprofessional and wastes space.

Method 1: a cleaner

The easiest fix is a cleaner that collapses runaway blank lines automatically. textscrubr reduces any run of three or more line breaks to a single blank line between paragraphs, trims blank lines at the very start and end, and removes trailing whitespace, all while keeping your real paragraph breaks and structure.

Method 2: find and replace with regex

In a regex-capable editor:

  1. Search for \n{3,} (three or more consecutive line breaks).
  2. Replace with \n\n (a single blank line).

This leaves exactly one blank line between paragraphs. If your editor uses a different newline representation, you may need to enable regex mode or adjust the pattern, but the idea is the same: collapse runs of blank lines down to one.

Keep one break between paragraphs

The goal is not to remove all blank lines, it is to keep a single, consistent break between paragraphs. A single blank line separates paragraphs cleanly in most contexts, including Markdown, where a blank line is what actually creates a new paragraph. Removing every blank line would merge your paragraphs into one block.

Watch code blocks

Inside code, blank lines can be intentional. A structure-aware cleaner leaves code spacing alone and only collapses blank lines in ordinary prose, so you tidy the document without disturbing code samples.

Quick recap

Collapse runs of three or more line breaks to one, keep a single break between paragraphs, and leave code alone. A cleaner does all three at once.

Scrub this text in one click

textscrubr strips the hidden characters, em dashes, and double spaces, and keeps your lists, headings, and code exactly where you put them. Free, and it runs entirely in your browser.

Clean my text free →

Frequently asked questions

How do I remove extra blank lines from text?

Paste it into a cleaner that collapses runs of blank lines to one, or use the regex \n{3,} replaced by \n\n in an editor. This keeps a single clean break between paragraphs.

Should I remove all blank lines?

No. Keep one blank line between paragraphs, especially in Markdown, where a blank line creates a new paragraph. Removing every blank line merges your paragraphs into one block.

Will removing blank lines affect my code?

With a structure-aware cleaner, no. It leaves blank lines inside code blocks alone and only collapses extra blank lines in ordinary prose.