What the empty line remover does
Text copied from web pages, PDFs, emails and spreadsheets often arrives with blank lines between every line, or with long gaps in places. The tool cleans that up in one step and shows how many blank lines it found.
Three ways to remove blank lines
- Remove all blank lines: every empty line goes, and the text becomes one block.
- Collapse several blank lines into one: paragraphs stay separated, but a gap of five blank lines becomes one. This suits normal writing.
- Remove blank lines at the start and end only: the middle of the text is left as it is.
Lines that look empty but are not
A line that contains only spaces or tabs looks empty, but a simple tool does not count it as empty. Keep Treat lines with only spaces as empty switched on, and those lines are removed too. Trim spaces at the start and end of each line also cleans the lines that stay.
Remove blank lines in other tools
- Notepad++: Edit, Line Operations, Remove Empty Lines. The command Remove Empty Lines (Containing Blank Characters) also removes lines that hold only spaces.
- VS Code: open Find and Replace, switch on regular expressions, search for
^\s*\nand replace with nothing. - Linux and macOS:
grep -v '^[[:space:]]*$' file.txtorsed '/^[[:space:]]*$/d' file.txt. - PowerShell:
Get-Content file.txt | Where-Object { $_.Trim() -ne '' }
Related tools
Delete repeated lines with remove duplicate lines, repeated words with remove duplicate words, and count what is left with the non-empty line counter. You can also sort lines or find and replace text. See the guide to removing duplicate lines for more ways to clean a list.