Remove blank lines from text, or keep one between paragraphs

Paste text with gaps in it and the tool deletes the blank lines, either all of them or all but one between paragraphs.

Live demo · real result from this tool
Mode

Result

First line Second line Third line

Processed on your device — nothing is uploaded.

How to use Remove Empty Lines

  1. Paste your text into Your text.
  2. Choose a Mode: Remove all blank lines for a tight list, or Keep one between paragraphs for prose.
  3. Decide on Treat lines with only spaces as empty. It is ticked by default, which is usually what you want.
  4. Copy the result.

What it does and when to use it

Blank lines creep in when you copy from web pages, PDFs, emails and chat apps. Some sources add an empty line after every line, so a list of 20 names turns into 40 lines. This tool deletes those gaps.

Pick the mode by what you are cleaning:

  • Remove all blank lines suits lists, CSV data, log files and code snippets, where every line should hold something. The result is ready to sort, number or paste into a spreadsheet.
  • Keep one between paragraphs suits articles, letters and notes, where the space between paragraphs carries meaning but double or triple gaps look untidy.

The space-only option matters more than it seems. A line that holds a single space looks empty but is not, and many tools treat it as content. Leaving the option on catches these hidden lines.

After cleaning a list, you can sort the lines, remove duplicate lines or add line numbers.

How it works

The text is split at every line break. In Remove all blank lines mode, each line is tested: if it is empty (or, with the option on, has nothing but whitespace), it is dropped. The other lines are joined back with line breaks.

In Keep one between paragraphs mode, a blank line is kept only if the line before it held content. That keeps the first blank line of each run and drops the rest. Kept blank lines are emptied, so a line of spaces becomes a truly empty line. Leading and trailing blank lines are then trimmed off. The work happens in your browser.

Worked examples

A list with gaps. “Line one”, two empty lines, “Line two”, a line of three spaces, “Line three”. With the default settings every gap goes: Line one, Line two, Line three on three consecutive lines.

Paragraphs. “Para one”, three empty lines, “Para two”, a space-only line, “Para three”. In Keep one between paragraphs mode the result is the three paragraphs, each separated by exactly one empty line.

Exact emptiness only. “a”, a line of three spaces, “b” with Treat lines with only spaces as empty unticked. The space line counts as content, so nothing is removed and the text comes back unchanged.

Limits and tips

Frequently asked questions

Is a line with only spaces treated as empty?
Yes, by default. "Treat lines with only spaces as empty" also catches lines that hold only tabs. Untick it to remove only lines that are truly empty, with zero characters.
How do I keep my paragraphs separate?
Choose "Keep one between paragraphs". Any run of blank lines becomes exactly one empty line, so paragraphs stay apart but the extra gaps go.
Are blank lines at the very start or end removed?
Yes, in both modes. In "Keep one between paragraphs" mode, blank lines are kept only between two lines of content.
Does it change the lines that have text?
No. Lines with content are kept exactly as they were, including any spaces at the start or end. Use Trim Lines if you also want those edges cleaned.

Written by the ToolsRift team · Last updated

Pages are drafted with AI assistance and checked by automated tests. How we write and check pages.

Was this tool useful?

Report a problem

Start typing to search every tool.

↑ ↓ to moveEnter to openEsc to close