How to use
Paste the text
Paste into the Text with empty lines box, or press Try sample to load a short column of order numbers with empty lines and lines that hold only spaces or a tab.
Choose what to keep
Pick Remove all empty lines, Keep one blank line between blocks, or Only at the start and end. Untick Count lines with only spaces or tabs as empty to keep those, and tick the trim option if needed.
Check the count and copy
The counter shows lines in, lines out and lines removed. When the Result pane looks right, press Copy, or Download .txt to save it as a file.
Why Remove Empty Lines
- Removes empty lines and lines with only spaces or tabs.
- Can keep one blank line between paragraphs, or trim blank lines only at the edges.
- Optional trim of the lines that remain.
- Shows lines in, out and removed, and never reorders your text.
Example: a column pasted from Excel
The sample below is what a column of order numbers looks like after copying it from a sheet with empty cells. Some gaps are truly empty, one holds three spaces and one holds a tab. The last line is indented with spaces.
With Remove all empty lines, 12 lines go in and 6 come out: Order ID, 10452, 10453, 10457, the Notes line and the indented line. The indented line keeps its spaces unless the trim option is ticked. With Keep one blank line between blocks and trim on, each group of gaps becomes a single blank line and the indented line is trimmed, giving 10 lines.
| Line in the input | Remove all empty lines | Keep one blank line, trim on |
|---|---|---|
| Order ID | Order ID | Order ID |
| (empty) | removed | one blank line |
| 10452 | 10452 | 10452 |
| (3 spaces), (empty) | removed | one blank line |
| 10453 | 10453 | 10453 |
| (empty), (empty) | removed | one blank line |
| 10457 | 10457 | 10457 |
| (tab) | removed | one blank line |
| Notes: second block starts here | Notes: second block starts here | Notes: second block starts here |
| indented line | indented line | indented line |
Removing blank lines in other programs
If you prefer to stay inside the program you are using, these methods do the same job. Most of them remove every blank line, so to keep single gaps between paragraphs, paste the text here and choose Keep one blank line between blocks. Always keep a copy of the original before a bulk delete in a spreadsheet.
- Excel: select the column, then Home, Find and Select, Go To Special, Blanks. Then use Delete, Delete Sheet Rows. Check first that no other column has data in those rows.
- Notepad++: Edit, Line Operations, Remove Empty Lines. The Containing Blank characters version also removes lines with only spaces or tabs.
- VS Code: open Find and Replace, turn on regular expressions, search for ^\s*\n and replace with nothing.
- Command line: grep -v '^[[:space:]]*$' file.txt prints every line that is not blank.