Remove Empty Lines

Remove empty lines from any text in one paste. Blank lines disappear as you type, including the sneaky ones that only contain spaces or tabs, and you can choose to keep one clean gap between paragraphs instead of deleting every break.

Remove Empty Lines tool

How to use it

  1. Paste text that has blank lines scattered through it.
  2. Decide whether whitespace-only lines count as empty and whether to keep a gap between paragraphs.
  3. Copy or download the cleaned text.

What counts as an empty line?

An empty line is a line with nothing between two line breaks. The trouble is that many lines only look empty. A space, a tab or a non-breaking space pasted from a web page leaves a line that is blank on screen but not empty to a computer, so a simple search for two line breaks in a row misses it.

strictly empty:   line === ""
visually empty:   line.trim() === ""

This tool uses the second rule by default, which is what most people mean. Turn the first option off if you need to keep lines that deliberately hold only whitespace, such as indentation markers in code.

Worked example

Input: Apples ⏎ ⏎ ⏎ Pears ⏎ (spaces) ⏎ Plums
Result: Apples ⏎ Pears ⏎ Plums
Input: Same text with ‘Keep one blank line’ on
Result: Apples ⏎ ⏎ Pears ⏎ ⏎ Plums

What each option does

SettingBlank lineLine with only spacesGap between paragraphs
DefaultRemovedRemovedRemoved
Whitespace option offRemovedKeptRemoved
Keep one blank lineCollapsedCollapsedExactly one kept
Trim every lineRemovedRemovedRemoved, and spaces stripped from text lines
Keep one blank line + trimCollapsedCollapsedOne kept, text lines tidied

Why blank lines pile up

Blank lines creep in whenever text moves between programs. Copying from a PDF often inserts an empty line after every line of print. Exports from spreadsheets and databases leave gaps where a row was empty. Email clients add spacing around quoted replies, and text copied from a web page can arrive with a blank line between every paragraph and several more at the end.

Deleting every gap or keeping paragraphs

Removing all empty lines packs the text into a solid block, which suits lists, code, CSV data and anything a script will read one line at a time. It is the wrong choice for prose, where the gap between paragraphs carries meaning. The ‘Keep one blank line’ option handles that case: it squeezes any run of blank lines down to a single one, so three or four stray breaks between paragraphs become one clean separation.

Lines that only look empty

The most common reason a find-and-replace fails to clear blank lines is invisible whitespace. A line holding a single space or tab is not technically empty, so editors treat it as content. This tool counts those lines as empty by default. The trim option goes a step further and strips leading and trailing spaces from the lines that do contain text, which is useful after pasting indented or right-padded data.

Nothing inside a line changes unless you turn trimming on, and the order of your lines is never altered. Everything runs in your browser, so pasted text stays on your device.

Common uses

  • Cleaning text copied from PDFs and web pages
  • Tidying lists before pasting into a spreadsheet
  • Preparing line-by-line data for a script or import
  • Fixing double-spaced email replies
  • Removing trailing blank lines at the end of a file

When to use it

  • You pasted a list from a PDF and every item has an empty line after it.
  • You need to remove blank lines from a CSV export before importing it.
  • A find-and-replace for double line breaks did nothing because the blank lines contain spaces.
  • You want to keep paragraph spacing but get rid of the extra gaps between some paragraphs.
  • A config or log file has blank lines you want gone before comparing it with another version.

Related tools

Remove Lines Containing deletes lines that include a particular word or phrase, which is the tool to use when the unwanted lines are not blank.

Remove Line Breaks joins broken lines back into flowing paragraphs, the right choice when text has a hard break at the end of every line rather than empty lines between them.

Remove Duplicate Lines keeps only the first copy of each repeated line, and it also drops blank lines as it goes.

Frequently asked questions

Paste the text into the box and the empty lines are removed immediately. By default lines that contain only spaces or tabs are removed too, since they look blank but would be missed by a simple search.
Those lines usually contain a space, a tab or a non-breaking space, so they are not truly empty. This tool treats whitespace-only lines as empty by default, which clears them in one step.
Yes. Turn on ‘Keep one blank line between paragraphs’. Any run of blank lines is reduced to exactly one, so paragraphs stay separated while the extra gaps disappear.
No, unless you tick the trim option. Without it, every line with content passes through exactly as it was, in the same order. Trimming only removes spaces at the very start and end of each line.
Paste the column here, clean it, and paste it back. In a spreadsheet the usual alternative is filtering for blanks and deleting those rows, which takes several steps and is easy to get wrong with rows that hold a space.
Yes, with the Remove Lines Containing tool. It deletes, or keeps only, the lines that match one or more words you type, which is the better fit when the lines you want gone are not blank.
No. The cleanup runs entirely in your browser. Your text is saved only in your own browser so it survives a reload, and you can clear it at any time.