How to use the remove empty lines
- 1Paste your text into Text with blank lines.
- 2Under Blank lines, choose Remove all or Keep one between blocks.
- 3Keep Count lines with only spaces or tabs as empty ticked to catch lines that look empty but aren't.
- 4Copy the result from Text without empty lines.
Example
Name,Score Ana,12 Lee,9 Tom,15
Name,Score Ana,12 Lee,9 Tom,15
Default settings. Six empty lines are removed, including the line with three spaces and the empty line left by the final line break.
Blank vs whitespace-only lines
A line can look empty but contain spaces or tabs, which is common in text copied from web pages, spreadsheets and code editors. With Count lines with only spaces or tabs as empty ticked (the default), those lines are removed too. Untick it to remove only lines that are truly empty.
Remove trailing spaces from every line also strips spaces and tabs at the end of the lines that remain, which keeps diffs and CSV values clean.
Collapsing multiple blank lines
Keep one between blocks replaces any run of blank lines with a single blank line and removes blank lines at the start and end. With the example above it gives Name,Score, a blank line, Ana,12, a blank line, Lee,9, a blank line and Tom,15. This is the same as the “collapse blank lines” setting in many code formatters.
Cleaning CSV and log files
An empty line in a CSV file is read as an empty record by many importers, and a trailing blank line can create an extra empty row. Removing blank lines before importing avoids both.
Rows that contain only delimiters, such as ,,,, are not empty lines, so they stay. Remove them with remove lines containing using the regular expression ^,*$. Windows (CRLF) line endings are handled; the result uses plain line feeds.
Keeping paragraph spacing
If the blank lines separate paragraphs you want to keep, choose Keep one between blocks rather than Remove all. If the problem is the opposite, lines broken in the middle of sentences, use remove line breaks to join lines while keeping paragraph breaks.
Is my text private?
This tool runs entirely in your browser. Your text is not uploaded to our servers.
