Remove blank lines from text

Remove blank lines from text by dropping every empty row from a multi-line block. The default treats both fully empty lines and lines containing only spaces or tabs as blank, so a paragraph break that has stray indentation also disappears. Turn the Whitespace toggle off to keep whitespace-only rows. Order is preserved, line endings are kept LF, and the transform runs in your browser. For deduping, see remove duplicate lines.

Input
Line 1:1 LF cloud_done Saved locally
Result Remove Empty Lines
0 lines 0 chars

How blank-line removal works

The input is split on \n or \r\n, then each line is tested. With Whitespace on (default), a line is blank if its trimmed value is empty, which catches truly empty rows and rows containing only spaces, tabs, or other Unicode whitespace. With it off, only fully empty rows are dropped; a row with a single space survives.

Surviving lines are rejoined with \n, so the relative order is preserved. The very last newline of the input is dropped if it produced a trailing empty element after the split, which avoids a phantom blank row at the end.

Common workflows pair this tool with others. Run trim whitespace first if you want clean ends on every surviving row. Run remove duplicate lines after if multiple identical rows should also collapse. The transform itself is a JavaScript filter, evaluated locally in your browser on every keystroke.

How to use remove blank lines from text

  1. 1Paste your text into the input panel on the left.
  2. 2Read the result with blank rows removed on the right.
  3. 3Leave Whitespace on to also drop lines containing only spaces or tabs.
  4. 4Turn the toggle off if rows of pure whitespace should survive.
  5. 5Click Copy to grab the cleaned text.

Keyboard shortcuts

Drive TextResult without touching the mouse.

Shortcut Action
Ctrl FOpen the find & replace panel inside the input Plus
Ctrl ZUndo the last input change
Ctrl Shift ZRedo
Ctrl Shift EnterToggle fullscreen focus on the editor Plus
EscClose find & replace, or exit fullscreen
Ctrl KOpen the command palette to jump to any tool Plus
Ctrl SSave current workflow draft Plus
Ctrl PRun a saved workflow Plus

What this tool actually does

Drops empty rows by default

A line containing zero characters between line breaks is filtered out. The relative order of remaining lines is preserved, and the line endings between them stay as line feeds in the output.

Whitespace-empty matches optional but on by default

With Whitespace on, the test is line.trim() !== '', so lines with only spaces, tabs, or other Unicode whitespace are also treated as blank. Turn it off to keep those rows, which can matter in fixed-width layouts where a space line is meaningful.

LF and CRLF input both work

The split regex matches \r?\n, so files saved with Windows or Unix line endings produce the same output. The rejoin uses LF; if you need CRLF back, follow with find and replace on \n.

Single linear pass, predictable order

Implemented as Array.prototype.filter over the split array. There is no sorting or hashing involved, so a 100k-row input drops blanks in one walk. The order of surviving rows is exactly the order they appeared in the input.

Runs in your browser, no upload

The transform is a JavaScript filter evaluated on every keystroke in the page. Nothing leaves the page, no log of the input is kept on our servers, and the output panel updates with no network round trip.

Worked example

With Whitespace on, the empty row and the row of three spaces both disappear, leaving the three real lines in order.

Input
First line

Second line
   
Third line
Output
First line
Second line
Third line

Settings reference

Setting or behaviour Effect on output
Whitespace on (default) Lines that are empty or contain only whitespace are dropped.
Whitespace off Only fully empty lines are dropped. A row with one space survives.
Order of surviving lines Preserved exactly as in the input.
Line endings Input split on \n or \r\n; output joined with \n.
Internal whitespace on surviving lines Untouched. Use trim whitespace beforehand if surviving rows should also be edge-trimmed.
Trailing newline at end of input Suppressed if it produced an empty final element. No phantom blank row at the end.

FAQ

Will it drop lines with only spaces or tabs?
Yes, by default. The Whitespace toggle is on out of the box, so any line that is empty after trimming whitespace gets dropped. Turn the toggle off if a row of spaces should be treated as content.
Does it preserve the order of surviving lines?
Yes. The pass is a linear filter that keeps each surviving line in the position it appeared. No sorting or shuffling happens. Pair with remove duplicate lines if you also want repeated rows collapsed.
What about lines with stray non-printing characters?
A line with a non-printing character that is not classified as whitespace will not be dropped, because it is technically content. Run remove control chars or remove zero-width first to clean those, then this tool will see the line as blank.
Does it change my line endings?
The output uses LF (\n) regardless of input. If your downstream consumer needs CRLF, run the result through find and replace with \n as the pattern and \r\n as the replacement.
Is the input ever uploaded?
No. The filter is a single JavaScript expression evaluated locally in your browser on every keystroke. Nothing about your text leaves the page or is logged on our side.