What Does Remove Blank Lines Do?
A remove blank lines tool deletes the empty lines from a piece of text. Blank lines creep in constantly: when you copy text from PDFs, web pages, emails and word processors, when you export data from spreadsheets or databases, when code is generated automatically, or when a list has been edited many times. They make text look untidy, break some imports and scripts, and waste space when you're working with a character or line limit.
This free tool removes them in one click, with three modes. Remove all blank lines produces compact text with no gaps, ideal for lists and data. Collapse multiple blank lines keeps a single blank line between paragraphs but removes the extra ones, ideal for articles, emails and code. Trim leading and trailing removes only empty lines at the very start and end. Lines that contain only invisible spaces or tabs are detected too, which is a common reason why "empty-looking" lines survive other clean-up attempts.
How to Remove Empty Lines
- Paste your text or drop a text file.
- Choose a mode: remove all, collapse to one, or trim the ends.
- Decide whether whitespace-only lines count as blank. Usually they should.
- Copy or download the cleaned text.
Modes Compared
| Mode | Before | After |
|---|---|---|
| Remove all | A ¶ ¶ ¶ B ¶ ¶ C | A ¶ B ¶ C |
| Collapse | A ¶ ¶ ¶ B ¶ ¶ C | A ¶ ¶ B ¶ ¶ C |
| Trim ends | ¶ ¶ A ¶ ¶ B ¶ ¶ | A ¶ ¶ B |
Common Uses
- Text copied from PDFs, which often has blank lines between every line of the original.
- Lists and data for import into spreadsheets, CRMs and email tools, where blank rows cause errors.
- Code and configuration files with excessive spacing after generation or merging.
- Emails and documents where double spacing made the text unnecessarily long.
- Subtitles, lyrics and poetry where you want consistent single spacing between stanzas.
Features
- Three modesRemove all, collapse runs, or trim the ends.
- Invisible whitespace detectionLines with only spaces or tabs are treated as blank.
- Trailing space clean-upOptionally strip spaces at the end of lines.
- Line countSee how many lines were removed.
- Any line endingsWindows (CRLF) and Unix (LF) handled.
- PrivateProcessed in your browser, never uploaded.
Removing Blank Lines in Other Tools
In many code editors you can use find-and-replace with a regular expression: search for ^\s*$\n and replace with nothing. In Microsoft Word, replace ^p^p with ^p repeatedly. On the command line, grep -v '^\s*$' file.txt or sed '/^\s*$/d' remove empty lines. This tool gives the same results without remembering any syntax, and our Find & Replace tool supports regular expressions if you need something more specific.
Line Endings Explained
Text files mark the end of each line with invisible characters. Windows uses a carriage return plus line feed (CRLF), while macOS, Linux and the web use a single line feed (LF). When text moves between systems, these can get mixed up and create lines that look blank but aren't, or double spacing that appears only in some programs. This tool normalises both kinds of line ending, so blank lines are detected correctly whatever system the text came from, and the output uses standard line feeds that work everywhere.
Sometimes what looks like a blank line contains a single space, a tab or a non-breaking space pasted from a web page. Keeping "Treat lines with only spaces/tabs as blank" ticked catches these too. For other invisible characters, such as zero-width spaces, run the text through the Remove Extra Whitespace tool as well.
Frequently Asked Questions
Can I remove blank lines from code?
Yes. "Collapse" is usually best for code, keeping single blank lines between blocks.
How do I remove empty lines but keep paragraphs?
Choose "Collapse multiple blank lines into one". Paragraphs stay separated by exactly one blank line.
Why do some blank lines not get removed?
They may contain invisible spaces or tabs. Keep "Treat lines with only spaces/tabs as blank" ticked to remove them.
Does it change the rest of my text?
No. Only blank lines are removed (and trailing spaces, if you tick that option).
How do I fix text copied from a PDF?
Use "Remove all blank lines" first. If sentences are still split across lines, the Remove Extra Whitespace tool can join lines into paragraphs.
Is my text uploaded?
No. Everything runs locally in your browser.