About Remove Empty Lines
Text copied from a PDF, an email or a web page often comes with extra gaps: two or three blank lines where one would do, or a blank line between every line of a list. Paste it in and the gaps are gone in the result on the right, with a count of how many lines were removed.
Sometimes you want the gaps gone, as with a list. Sometimes they carry meaning, as with paragraphs in a letter, and you only want the repeats gone. Those are the two modes: Remove all, and Keep one between paragraphs.
The second problem this solves is the blank line that is not blank. A line holding a few spaces or a tab looks identical to an empty one, and it is often what makes a search or an import misbehave. Those are treated as blank by default.
How it works
The text is split into lines after normalizing Windows and Mac line endings. Each line is tested for blankness: by default, a line of nothing but whitespace counts, including non-breaking spaces from web pages. With Treat lines with only spaces as blank turned off, only lines with no characters at all count.
In Remove all mode, those lines are dropped. In Keep one between paragraphs mode, each run of blank lines becomes a single blank line, and any at the very start or end of the text are removed. Trim spaces at line ends separately removes trailing spaces and tabs from the lines that stay.
Spaces at the start of a line are never touched, so indentation in code or a nested list survives. The line endings in the result are single line feeds, which every current system reads correctly.
How to use Remove Empty Lines
- Paste into the Text with blank lines box, or press Upload. Try an example shows a list with several kinds of gap.
- Under Blank lines, choose Remove all or Keep one between paragraphs.
- Leave Treat lines with only spaces as blank on, unless those lines matter to you.
- Turn on Trim spaces at line ends if you also want trailing spaces gone.
- Press Copy, or Ctrl or Cmd + Enter, to copy the cleaned text. Download saves it as no-blank-lines.txt.
A note with uneven gaps, using Keep one between paragraphs
Dear team,
The office is closed on Friday.
Thanks,
AnnaDear team,
The office is closed on Friday.
Thanks,
AnnaThe third blank line holds three spaces and is treated the same as the others. In Remove all mode, the same text comes out as four lines with no gaps at all, and the count reads 5 removed rather than 3.
When it helps
- Cleaning a list pasted from a website, where each item arrives with a blank line after it.
- Tidying an email or document draft with uneven spacing, without losing the paragraphs.
- Preparing a list for import, when a blank row would create an empty record.
- Removing the gaps from a config or log excerpt before pasting it into a ticket.
Tips for a better result
- If text from a PDF has a line break in the middle of each sentence, removing blank lines will not fix that. Use the Text Joiner with a space to rebuild the lines.
- Check the removed count. A figure of about half the lines usually means every other line was blank, which is common when pasting between programs.
- Turn off the whitespace option when working with code or Markdown where a line of spaces is deliberate, for example inside a fenced block.
Good to know
- It only handles whole lines. Extra spaces between words stay as they are, and Find and Replace can deal with those using a regex such as
{2,}. - It has no idea what a paragraph means. A single line break inside a paragraph stays, and two separate items with one gap are treated as two paragraphs.
- Zero-width characters are not treated as whitespace, so a line holding only one of those stays.
Questions people ask
Will this remove the spacing between my paragraphs?
Only in Remove all mode. Choose Keep one between paragraphs and every run of blank lines shrinks to one, so your paragraphs stay separate.
Why do some lines look blank and yet stay in the result?
With Treat lines with only spaces as blank turned off, a line with a space in it counts as text. Turn the option on. If a line still remains, it may hold a zero-width character, which looks like nothing but is not whitespace.
Does it change the indentation in my code?
No. Spaces at the start of a line that has text on it are kept. Only the trim option touches spaces, and only at the end of a line.
What to use next
- Remove Duplicate Lines: to clear repeated lines from the same list.
- Text Joiner: when text from a PDF needs its broken lines rejoined.
- Line Counter: to see how many blank lines a text has before you touch it.
- Remove Line Breaks: when the breaks inside each paragraph have to go as well
Last reviewed . Read our editorial policy.