Remove empty lines from text

Paste text and delete the blank lines, or squeeze each run down to one. Nothing leaves your browser.

How it works

  1. Paste your text
  2. Choose what counts as empty
  3. Copy the tighter text

What counts as an empty line

A line is empty when it has no characters at all. With the first option on, which is the default, a line that holds only spaces or tabs is empty too, because it looks blank on screen. Turn the option off and such a line stays, with its spaces. Only space and tab characters are treated this way. A line holding a non-breaking space or another invisible character is not seen as empty, so it stays. Every line that is kept is copied exactly as you typed it, including spaces at its start and end. The tool deletes whole lines and never edits the text inside one.

Keeping one blank line between blocks

Removing every blank line also glues paragraphs together. Turn on the second option and each run of empty lines shrinks to a single blank line instead of disappearing, so a gap of five lines between two paragraphs becomes a gap of one. The line that survives is the first of the run, as typed. Blank lines at the very top or end of the text are treated the same way: a run of them leaves one. If you want none at all, leave this option off.

Line endings and the last line

Windows, old Mac and Unix line endings are each read as one line break, and the result uses plain Unix breaks. A line break at the end of your text means there is an empty last line, so it is removed with the other empty lines and the result has no trailing break. With the keep-one option on, that last empty line survives as a single blank line at the end. Empty text gives empty text.

What it will not do

It does not remove the spaces inside lines or collapse double spaces; the extra spaces page does that. It does not drop repeated lines either. For blank lines, trimming, repeats and sorting in one go, the list cleaner does it. The result shows how many lines came in, how many are left and how many were removed. The work happens in this tab and nothing is uploaded. Your choices are saved in this browser, the text is not. Text up to 1,000,000 characters is handled.

Frequently asked questions

Why are some blank-looking lines still there?

They hold a character other than a space or a tab, such as a non-breaking space copied from a web page. Those are not counted as empty. Turning off the spaces-and-tabs option makes the tool stricter, never looser.

Can I keep one blank line between paragraphs?

Yes. Turn on Keep one blank line between blocks. A run of 4 empty lines becomes 1, and text with no blank lines is unchanged.

Does it remove the empty line at the end of my text?

Yes by default. A trailing line break counts as an empty last line, so the result ends right after the last word. With the keep-one option on, a single blank line is kept there.

Will it change the spacing inside my lines?

No. Lines are kept or deleted whole. A kept line with 3 spaces in front still has 3 spaces. To tidy those, use the extra spaces page.

Can I remove blank lines in a list and also sort it?

Not here. The list cleaner drops blank lines, trims, removes repeats and sorts in one pass.