Skip to content
cliplimeClipLime

Remove empty lines from text

Delete blank lines, or keep just one between paragraphs.

0 characters, 0 lines

What to clean up

Spaces and lines

Removes spaces and tabs at the start and end of every line.

Turns any run of spaces and tabs into a single space.

Leaves the spaces at the start of a line alone, for code and outlines. Not available while trimming.

Empty lines

A line with only spaces or tabs counts as empty. Keeping one in a row leaves a single blank line between paragraphs.

Joins all the lines into one, for text copied from a PDF or an email that was wrapped.

Characters and markup

Removes tags, comments, scripts and styles, and turns entities such as & into characters.

Changes curly single and double quotes and apostrophes to plain ones.

Changes em dashes and en dashes to a plain hyphen.

Changes non breaking spaces and other special spaces to a normal space.

Removes zero width spaces, byte order marks and soft hyphens. Joiners used by emoji and some scripts are kept.

Line breaks in the result are always plain line feeds, whatever the original text used.

Your text stays in your browser. Nothing you type or paste is sent anywhere.

At a glance

What counts as empty
A line with nothing on it, or with only spaces, tabs or non breaking spaces.
Two ways
Remove all empty lines, or keep one blank line wherever there was a run of them.
Everything else
Lines with text are left exactly as they were, unless you turn on another fix.
Counted
The summary says how many empty lines were removed.
Zero width spaces
A line holding only a zero width space looks empty but is not. Turn on Remove invisible characters first.
Line endings
The result uses plain line feeds, whether the text came from Windows, Mac or Linux.
Privacy
Runs in your browser. Your text is never uploaded.

How to do it

  1. 1

    Paste your text

    Type or paste into the box, or load a plain text file.

  2. 2

    Choose what to do

    Remove all deletes every empty line. Keep one in a row leaves a single blank line between paragraphs.

  3. 3

    Check the count

    The summary under the result says how many empty lines went, and the character count shows the saving.

  4. 4

    Copy or download

    Press Copy for the clipboard or Download for a text file.

Remove all, or keep one

The right choice depends on what the text is for.

  • Remove all suits anything where each line is an item: lists, logs, CSV rows, URLs, keywords, code listings. The result is solid with no gaps, so it can go straight into a spreadsheet, a script or a form.
  • Keep one in a row suits prose. A gap between paragraphs is meaningful, but three or four in a row is a mistake. This setting turns every run of empty lines into a single blank line and leaves single ones alone.

If you also want the lines in order or the repeats gone, follow up with sort lines or the duplicate line remover.

Why empty lines appear in the first place

  • Double spacing from exports. Some programs write a blank line after every line, or a file has been converted twice between line ending styles so each break turned into two.
  • Copying from web pages, PDFs and emails, where paragraph spacing arrives as blank lines.
  • Lines that only look empty. A line with a few spaces, a tab or a non breaking space shows nothing but is not zero length, so a simple search for empty lines misses it. This tool counts such lines as empty.
  • Invisible characters. A line holding only a zero width space is not treated as empty, since it counts as text. Switch on Remove invisible characters, which runs before the empty line step, to include it.

Doing it in an editor or on the command line

In an editor that supports regular expressions, such as VS Code, turn the regex option on, search for ^\s*\n and replace with nothing. On the command line, sed '/^[[:space:]]*$/d' file.txt deletes lines that are empty or hold only whitespace. A plain sed '/^$/d' deletes only lines of zero length, so lines with spaces survive.

This page does the same thing without a command or a pattern, and shows a count of how many lines went.

Questions people ask

How do I remove blank lines from text?

Paste the text and leave Remove all selected. Every blank line is deleted, and the summary shows how many.

Will it remove lines that contain only spaces?

Yes. A line with only spaces, tabs or non breaking spaces counts as empty and is removed.

How do I keep one blank line between paragraphs?

Choose Keep one in a row. Runs of two or more empty lines are cut to a single one, and single blank lines stay.

Why are some blank lines still there?

Probably a zero width space or another invisible character is on the line. Turn on Remove invisible characters in the options below the result and they will count as empty.

Does it keep the text on the other lines as it is?

Yes. Only empty lines are touched, unless you switch on another fix. Spaces, punctuation and the order of lines stay as they were.

Is my text uploaded?

No. Everything happens in your browser, and nothing you paste is sent anywhere.

Guides that help

All Text guides →