Remove Empty Lines

A remove empty lines tool deletes the blank lines from your text and leaves every other line as it was. Paste your text and the blank lines disappear, including lines that hold only spaces or tabs. You can also keep one blank line between paragraphs. It runs in your browser, so nothing is uploaded.

Runs in your browser. Your text is never uploaded.

How to use the remove empty lines

  1. Paste your text into the first box. The result appears beside it, or underneath on a phone, with the blank lines removed.
  2. Choose what to do with blank lines. Remove all blank lines gives one line after another. Keep one between paragraphs removes the extra gaps but keeps your paragraphs apart.
  3. Leave Count lines with only spaces or tabs as blank ticked unless those lines matter. Tick Remove spaces at the end of every line to tidy the lines that remain.
  4. Read the note under the result, which says how many blank lines were removed, then press Copy result or Download .txt.

How blank lines are found

The tool looks at your text one line at a time and decides whether each line is blank. It follows these steps.

  1. Split into lines. Your text is cut at every line break, whether it comes from Windows, Mac or Linux.
  2. Tidy line ends, if asked. Remove spaces at the end of every line deletes spaces and tabs after the last visible character. A line that held only spaces then becomes empty.
  3. Decide what is blank. An empty line has no characters at all. A line that holds only white space looks empty but is not. By default both count as blank. Untick Count lines with only spaces or tabs as blank to remove truly empty lines only. White space here means spaces, tabs, no-break spaces and the other characters Unicode marks as white space.
  4. Remove or collapse. Remove all blank lines drops every blank line. Keep one between paragraphs turns each run of blank lines into a single empty line and removes blank lines at the very start and end of the text.

Every line that is not blank is kept exactly as it was, in the same order. Only the blank lines change. The POSIX standard, which defines the rules behind Unix text tools, makes the same distinction: an empty line has no characters before its line break, and a blank line holds nothing but zero or more spaces or tabs, so every empty line is also a blank line.

Worked example

This shopping list has 9 lines. A middle dot (·) marks a space, an arrow (→) marks a tab and ↵ marks the end of a line:

Shopping·list


Milk··
···
Bread
→
Eggs

It has 5 blank lines: two empty lines after the heading, one line of spaces, one line holding a tab, and the empty line after the final line break. With the default settings all of them are removed and 4 lines remain. The other settings give these results:

SettingResultLines
Remove all blank lines (default)Shopping·list↵Milk··↵Bread↵Eggs4
Keep one between paragraphsShopping·list↵↵Milk··↵↵Bread↵↵Eggs7
Only remove truly empty linesShopping·list↵Milk··↵···↵Bread↵→↵Eggs6
Also remove spaces at line endsShopping·list↵Milk↵Bread↵Eggs4

Empty, blank and white space

LineLooks likeRemoved by default?Removed with spaces counted as text?
Empty lineNothing between two line breaksYesYes
Line of spacesEmpty, but holds spacesYesNo
Line with a tabEmpty, but holds a tabYesNo
Line with a no-break spaceEmpty, often pasted from web pages or WordYesNo
Line with text and trailing spacesNormal textNo, kept as it isNo, kept as it is

Frequently asked questions

What is the difference between an empty line and a blank line?

An empty line has no characters at all. A blank line looks empty but may hold spaces or tabs. This tool removes both by default; untick Count lines with only spaces or tabs as blank to remove only empty lines.

Can I keep the gaps between paragraphs?

Yes. Choose Keep one between paragraphs. Each run of blank lines becomes one empty line, and blank lines at the start and end are removed.

Why are some lines that look empty not removed?

They hold an invisible character that is not white space, such as a zero-width space. Paste the text into the remove extra spaces tool to standardize the spacing first.

How do I join all lines into one paragraph instead?

Use the remove line breaks tool. It replaces line breaks with spaces, so the lines become one block of text.

Is my text uploaded or stored?

No. The blank lines are removed in your browser and your text never leaves your device.

Sources and references