Remove Empty Lines
A remove empty lines tool deletes the blank lines from your text and leaves every other line as it was. Paste your text and the blank lines disappear, including lines that hold only spaces or tabs. You can also keep one blank line between paragraphs. It runs in your browser, so nothing is uploaded.
How to use the remove empty lines
- Paste your text into the first box. The result appears beside it, or underneath on a phone, with the blank lines removed.
- Choose what to do with blank lines. Remove all blank lines gives one line after another. Keep one between paragraphs removes the extra gaps but keeps your paragraphs apart.
- Leave Count lines with only spaces or tabs as blank ticked unless those lines matter. Tick Remove spaces at the end of every line to tidy the lines that remain.
- Read the note under the result, which says how many blank lines were removed, then press Copy result or Download .txt.
How blank lines are found
The tool looks at your text one line at a time and decides whether each line is blank. It follows these steps.
- Split into lines. Your text is cut at every line break, whether it comes from Windows, Mac or Linux.
- Tidy line ends, if asked. Remove spaces at the end of every line deletes spaces and tabs after the last visible character. A line that held only spaces then becomes empty.
- Decide what is blank. An empty line has no characters at all. A line that holds only white space looks empty but is not. By default both count as blank. Untick Count lines with only spaces or tabs as blank to remove truly empty lines only. White space here means spaces, tabs, no-break spaces and the other characters Unicode marks as white space.
- Remove or collapse. Remove all blank lines drops every blank line. Keep one between paragraphs turns each run of blank lines into a single empty line and removes blank lines at the very start and end of the text.
Every line that is not blank is kept exactly as it was, in the same order. Only the blank lines change. The POSIX standard, which defines the rules behind Unix text tools, makes the same distinction: an empty line has no characters before its line break, and a blank line holds nothing but zero or more spaces or tabs, so every empty line is also a blank line.
Worked example
This shopping list has 9 lines. A middle dot (·) marks a space, an arrow (→) marks a tab and ↵ marks the end of a line:
Shopping·list Milk·· ··· Bread → Eggs
It has 5 blank lines: two empty lines after the heading, one line of spaces, one line holding a tab, and the empty line after the final line break. With the default settings all of them are removed and 4 lines remain. The other settings give these results:
| Setting | Result | Lines |
|---|---|---|
| Remove all blank lines (default) | Shopping·list↵Milk··↵Bread↵Eggs | 4 |
| Keep one between paragraphs | Shopping·list↵↵Milk··↵↵Bread↵↵Eggs | 7 |
| Only remove truly empty lines | Shopping·list↵Milk··↵···↵Bread↵→↵Eggs | 6 |
| Also remove spaces at line ends | Shopping·list↵Milk↵Bread↵Eggs | 4 |
Empty, blank and white space
| Line | Looks like | Removed by default? | Removed with spaces counted as text? |
|---|---|---|---|
| Empty line | Nothing between two line breaks | Yes | Yes |
| Line of spaces | Empty, but holds spaces | Yes | No |
| Line with a tab | Empty, but holds a tab | Yes | No |
| Line with a no-break space | Empty, often pasted from web pages or Word | Yes | No |
| Line with text and trailing spaces | Normal text | No, kept as it is | No, kept as it is |
Frequently asked questions
What is the difference between an empty line and a blank line?
An empty line has no characters at all. A blank line looks empty but may hold spaces or tabs. This tool removes both by default; untick Count lines with only spaces or tabs as blank to remove only empty lines.
Can I keep the gaps between paragraphs?
Yes. Choose Keep one between paragraphs. Each run of blank lines becomes one empty line, and blank lines at the start and end are removed.
Why are some lines that look empty not removed?
They hold an invisible character that is not white space, such as a zero-width space. Paste the text into the remove extra spaces tool to standardize the spacing first.
How do I join all lines into one paragraph instead?
Use the remove line breaks tool. It replaces line breaks with spaces, so the lines become one block of text.
Is my text uploaded or stored?
No. The blank lines are removed in your browser and your text never leaves your device.
Related tools
- Remove Extra SpacesCollapse double spaces, trim lines and fix tabs and no-break spaces.
- Remove Line BreaksJoin broken lines into one paragraph, with options for paragraphs and hyphens.
- Duplicate Line RemoverDelete repeated lines and keep one copy, or keep only the unique ones.
- Sort LinesAlphabetize a list A to Z or Z to A, or sort it by number, length or at random.
- Online NotepadA plain notepad that autosaves in your browser, with copy and .txt download.
Sources and references
- The Open Group Base Specifications: Definitions (POSIX) — defines Blank Line and Empty Line
- Unicode Character Database: PropList.txt — lists the characters with the White_Space property