Format Code Now
/
TextRemove Empty Lines Next: Remove Extra Spaces ›

Remove Empty Lines

TX-10

Paste text and get it back without the empty lines. Lines that only hold spaces or tabs count as empty by default, and you can keep a single blank line between blocks instead.

Runs in your browser. Nothing is uploaded.

Text

Result

How to use it

  1. Paste your text into the input box, or open a text file and drop it on the box.
  2. Leave Treat lines with only spaces or tabs as empty ticked if such lines should go too.
  3. Tick Keep one blank line where a run of them was if you want to shrink gaps rather than remove them.
  4. Press Remove empty lines. The result updates as you type.
  5. Copy the result or download it as a .txt file.

What counts as an empty line

A line with no characters at all is empty. With the first option on, a line that holds only whitespace is empty as well: spaces, tabs and the other characters Unicode treats as white space. Turn that option off if lines with stray spaces should stay. Lines that contain any text are never changed, including their trailing spaces. For trimming those, use the Remove Extra Spaces tool.

Remove all blank lines or keep one

By default every empty line is removed and the text becomes a single block. With the second option on, each run of empty lines is replaced by one line, so triple spacing becomes single spacing and paragraphs stay apart. The first line of the run is the one kept, so a whitespace-only line can survive as it was. A run of blank lines at the very start or end of the text is also reduced to one line, not deleted.

Line endings

Windows (CRLF) and Unix (LF) line endings are kept as they were. If your text has a final line break, it is still there after the empty lines are gone. If every line in the input is empty, the result is an empty box, unless Keep one blank line is on, which leaves a single empty line. The tool changes nothing else: it does not trim, join or reorder lines.

Questions people ask

How do I remove blank lines from text?

Paste the text into the input box and press Remove empty lines. Every empty line is deleted and the lines with text stay in the same order. Lines that only have spaces or tabs are removed as well, unless you untick that option.

How do I remove empty lines but keep paragraph spacing?

Tick Keep one blank line where a run of them was. Runs of several empty lines then shrink to one, so each paragraph is still separated from the next but the large gaps are gone.

Why are some blank-looking lines not removed?

They probably hold a space, a tab or another invisible character. Tick Treat lines with only spaces or tabs as empty to catch spaces, tabs and other Unicode white space. A line holding a zero-width character or similar is not white space in this sense and is left alone.

Does it change the lines that have text?

No. Lines with text keep every character, including leading and trailing spaces. Only empty lines are removed or collapsed. To tidy spaces inside or at the ends of lines, use the Remove Extra Spaces tool as a second step.

Will it keep Windows line endings?

Yes. If the text contains CRLF line breaks the result uses CRLF, otherwise LF. A final line break at the end of the text is kept as well.

About this tool

A line is empty when it has no characters at all. With the first option on, a line that holds only whitespace (spaces, tabs, and other characters that count as white space in Unicode) is treated as empty too. By default every empty line is removed and the text becomes one block. With the second option, each run of empty lines is replaced by the first line of that run, which is useful for turning triple spacing into single spacing; blank lines at the very start or end of the text are kept as one line, not removed. Lines with text are never changed, and trailing spaces on them are left in place. Windows (CRLF) and Unix (LF) line endings are kept as they were.

Format Code Now: free, no ads, no accounts. Your input stays in your browser.