Remove Empty Lines
Remove empty lines from any text in one paste. Blank lines disappear as you type, including the sneaky ones that only contain spaces or tabs, and you can choose to keep one clean gap between paragraphs instead of deleting every break.
Remove Empty Lines tool
How to use it
- Paste text that has blank lines scattered through it.
- Decide whether whitespace-only lines count as empty and whether to keep a gap between paragraphs.
- Copy or download the cleaned text.
What counts as an empty line?
An empty line is a line with nothing between two line breaks. The trouble is that many lines only look empty. A space, a tab or a non-breaking space pasted from a web page leaves a line that is blank on screen but not empty to a computer, so a simple search for two line breaks in a row misses it.
strictly empty: line === ""
visually empty: line.trim() === ""
This tool uses the second rule by default, which is what most people mean. Turn the first option off if you need to keep lines that deliberately hold only whitespace, such as indentation markers in code.
Worked example
What each option does
| Setting | Blank line | Line with only spaces | Gap between paragraphs |
|---|---|---|---|
| Default | Removed | Removed | Removed |
| Whitespace option off | Removed | Kept | Removed |
| Keep one blank line | Collapsed | Collapsed | Exactly one kept |
| Trim every line | Removed | Removed | Removed, and spaces stripped from text lines |
| Keep one blank line + trim | Collapsed | Collapsed | One kept, text lines tidied |
Why blank lines pile up
Blank lines creep in whenever text moves between programs. Copying from a PDF often inserts an empty line after every line of print. Exports from spreadsheets and databases leave gaps where a row was empty. Email clients add spacing around quoted replies, and text copied from a web page can arrive with a blank line between every paragraph and several more at the end.
Deleting every gap or keeping paragraphs
Removing all empty lines packs the text into a solid block, which suits lists, code, CSV data and anything a script will read one line at a time. It is the wrong choice for prose, where the gap between paragraphs carries meaning. The ‘Keep one blank line’ option handles that case: it squeezes any run of blank lines down to a single one, so three or four stray breaks between paragraphs become one clean separation.
Lines that only look empty
The most common reason a find-and-replace fails to clear blank lines is invisible whitespace. A line holding a single space or tab is not technically empty, so editors treat it as content. This tool counts those lines as empty by default. The trim option goes a step further and strips leading and trailing spaces from the lines that do contain text, which is useful after pasting indented or right-padded data.
Nothing inside a line changes unless you turn trimming on, and the order of your lines is never altered. Everything runs in your browser, so pasted text stays on your device.
Common uses
- Cleaning text copied from PDFs and web pages
- Tidying lists before pasting into a spreadsheet
- Preparing line-by-line data for a script or import
- Fixing double-spaced email replies
- Removing trailing blank lines at the end of a file
When to use it
- You pasted a list from a PDF and every item has an empty line after it.
- You need to remove blank lines from a CSV export before importing it.
- A find-and-replace for double line breaks did nothing because the blank lines contain spaces.
- You want to keep paragraph spacing but get rid of the extra gaps between some paragraphs.
- A config or log file has blank lines you want gone before comparing it with another version.
Related tools
Remove Lines Containing deletes lines that include a particular word or phrase, which is the tool to use when the unwanted lines are not blank.
Remove Line Breaks joins broken lines back into flowing paragraphs, the right choice when text has a hard break at the end of every line rather than empty lines between them.
Remove Duplicate Lines keeps only the first copy of each repeated line, and it also drops blank lines as it goes.