Remove Empty Lines
Close up the gaps in your text. Remove every blank line, reduce repeated blank lines to a single one, or strip them only from the beginning and end, including lines that contain nothing but spaces or tabs.
- Runs in your browser
- No sign-up
- Free to use
How to use Remove Empty Lines
- Paste your text, list or code into the left box.
- Choose to remove all empty lines, keep one between paragraphs, or trim only the start and end.
- Leave the whitespace option on to treat lines containing only spaces as empty.
- Copy or download the compacted text.
Remove Empty Lines features
Three modes
Remove all blank lines, collapse runs of blank lines to one, or trim the edges.
Whitespace-only lines
Lines that look empty but contain spaces or tabs are detected too.
Line count
See how many lines were removed and how many remain.
Content untouched
Non-empty lines are kept exactly as they are, including their indentation.
Works on code and logs
Safe for source code, configuration files and log output.
Instant and private
Processed in your browser as you type.
When to use Remove Empty Lines
- Compacting lists copied from spreadsheets or web pages.
- Cleaning double-spaced text from emails and documents.
- Tidying code or configuration files with excessive blank lines.
- Preparing lists for import where blank rows cause errors.
- Reducing log output to meaningful lines.
Remove Empty Lines FAQ
What counts as an empty line?
A line with no characters. With the whitespace option on, lines containing only spaces or tabs also count, which is usually what you want.
How do I keep paragraph spacing?
Choose Keep one empty line between paragraphs. Multiple blank lines are reduced to a single one and paragraphs remain separated.
Does it change indentation?
No. Lines with content are left unchanged, including leading spaces and tabs.
Can it remove duplicate lines as well?
Use the Duplicate Text Remover for that; it can be combined with this tool.
Why does my file still end with a blank line?
Many editors show a final empty line when a file ends with a line break. That is normal and often required by coding standards.
Blank lines and whitespace-only lines
Blank lines accumulate whenever text is moved between programs. Copying a table from a web page inserts empty rows between cells, pasting from email adds a blank line after every paragraph, and exporting data often leaves gaps where values were missing. In lists and data, those blanks become empty entries that break imports or produce empty rows.
Not all blank lines are truly empty. Editors frequently leave spaces or tabs on otherwise empty lines, especially in indented code. A simple check for zero-length lines misses them, so they survive a naive clean-up. Treating whitespace-only lines as empty catches these cases.
For prose, blank lines carry meaning: they separate paragraphs. Collapsing runs of blank lines to a single one keeps that structure while removing excess space, which is the appropriate setting for articles and documentation.
In source code, style guides commonly limit consecutive blank lines to one or two. Collapsing them brings a file into line with such rules without touching the code itself.