Cadmeo

Remove Empty Lines

9
Lines in
6
Blank lines removed
3
Lines out
Result

Blank lines are deleted from text, with the choice of removing them all or collapsing runs of them into a single blank line. It also treats lines containing only spaces or tabs as blank, which is what catches the ones that look empty but are not.

How it works

  • Remove them all: every blank line goes, leaving a solid block of content lines. Right for a list.
  • Collapse runs to one: several consecutive blank lines become one, and leading and trailing blank lines are dropped. Right for prose, where blank lines separate paragraphs and you want to keep that structure.
  • Treating spaces-only lines as blank catches the lines a word processor or an email client leaves behind. A line with three spaces looks identical to an empty one and is not.

Line endings are normalised on the way in, so text copied from Windows, macOS or Unix behaves the same. Only line breaks are affected; nothing inside a line is touched.

Examples

Stripping every blank line

Text

3 paragraphs separated by 3, 1 and 2 blank lines

Result

3 lines out, 6 blank lines removed

Everything is packed together. Useful for a list, and wrong for prose, where the paragraph breaks carry meaning.

Collapsing runs instead

Text

The same text, collapse mode

Result

One blank line between each paragraph, none at the start or end

The paragraph structure survives, but the ragged spacing from pasting between applications does not.

A line of spaces

Line

Three space characters and nothing else

Result

Removed when "treat spaces-only lines as blank" is on

This is the case that makes people think a blank-line remover is broken. The line is not empty as a string, only as far as the eye can tell.

Frequently asked questions

Why are some blank lines left behind?

They probably contain spaces or tabs rather than nothing. Turn on "treat spaces-only lines as blank" and they will go. This is the single most common complaint about blank-line removers and it is always this.

When should I collapse rather than remove?

When blank lines carry meaning. In prose a blank line separates paragraphs, so removing them all runs the text together; collapsing keeps one break between paragraphs and tidies up the rest. For a list of values, remove them all.

Does collapse mode also remove blank lines at the start and end?

Yes. A run collapses to one blank line, but a leading or trailing blank line has nothing to separate, so it is dropped. That prevents the result starting with an empty line.

Does it change anything else about my text?

No. Content lines pass through byte for byte, including their indentation. Only whole blank lines are affected. Use the text cleaner or the whitespace remover if you also need to fix spacing inside lines.