Remove Empty Lines

Delete blank lines and lines with only spaces.

Result

first
second
third
3 lines · 18 bytes
  • 4 empty lines removed.

What counts as an empty line?

An empty line has no characters at all, like the gap between two paragraphs. A blank-looking line may also contain spaces or tabs that you cannot see. Text copied from emails, PDFs and web pages often has both kinds scattered through it.

This tool removes the truly empty lines, and by default also the lines that contain only spaces or tabs. You can choose to keep space-only lines instead. The text on the remaining lines is untouched, and the note tells you how many empty lines were removed.

How to use the Remove Empty Lines

  1. Paste your text.
  2. Choose whether lines with only spaces should be removed too.
  3. Copy the cleaned text and check the count of lines removed.

Real situations

When people use the Remove Empty Lines

  • 1

    Clean up pasted text

    Remove the extra gaps that appear when text is copied from a PDF, an email or a web page.

  • 2

    Compact a list before sorting

    Get rid of blank entries so they do not end up at the top of a sorted list.

  • 3

    Tidy a config or log file

    Squeeze out blank lines to make a long file shorter and easier to scan.

  • 4

    Prepare data for import

    Remove blank rows from a one-item-per-line list before you load it into another system or script.

FAQ

Remove Empty Lines: questions answered

What does the sample show?

The sample is "first", an empty line, "second", a line with three spaces, another empty line, "third" and a final empty line. With space-only lines removed, 4 empty lines go and first, second and third remain.

Should I remove lines with only spaces?

Usually yes, because they look empty but are not. Choose "Keep" if you need to preserve them, in which case only the truly empty lines go. In the sample that leaves the line with three spaces in place.

Will it remove spaces inside other lines?

No. Only whole lines are removed. To trim spaces at the start and end of lines, use the remove extra spaces tool.

Does it remove paragraph breaks?

Yes, because paragraph breaks are blank lines. If you want to keep one blank line between paragraphs, you would need to add them back afterwards.

Is the order of the other lines changed?

No. The remaining lines stay in the same order, exactly as you pasted them.

Can I remove duplicate lines at the same time?

Not here. Run the result through the remove duplicate lines tool as a second step.

Is this Remove Empty Lines free and private?

Yes. It is free with no sign-in, and every calculation runs inside your browser. Nothing you type is sent to a server or stored, and the page keeps working offline once it has loaded.

Private by design. No accounts, no cookies, no tracking. Everything you type stays on your device.

How we keep it that way