Remove Empty Lines
Strip blank and whitespace-only lines from text.
Use on any page (bookmarklet)
Want Remove Empty Lines without leaving the page you're on? Drag the button below to your bookmarks bar, then click it on any website to open Remove Empty Lines right there — it runs entirely in your browser.
Use responsibly: a bookmarklet runs on whatever page you click it on. Avoid sensitive sites such as online banking, payment, or healthcare pages — you run it at your own risk. Everything is processed locally and no data is sent anywhere. See our Terms.
- Show your bookmarks bar if it's hidden — Ctrl+Shift+B (⌘+Shift+B on Mac).
- Drag the button above onto the bookmarks bar.
- Open any website and click the bookmark — the Remove Empty Lines panel appears in the top-right corner. Use ✛ to move it between corners, or ›/‹ to tuck it against the edge and pull it back out.
- Click the bookmark again (or the ✕) to close it.
Note: a few sites with strict security policies may block bookmarklets.
Examples
Strip blank lines
Input
First Second Third
Output
First Second Third
Whitespace-only line removed
Input
alpha beta
Output
alpha beta
About this tool
This free online tool removes empty and blank lines from any text. Paste double-spaced content, messy copy-paste output, or a list with gaps and get back compact, single-spaced text. It can also drop whitespace-only lines and trim the lines it keeps. Everything runs in your browser with no upload.
How to use
- Paste your text into the input box (or click Sample to try it).
- Choose whether to drop whitespace-only lines and whether to trim each kept line.
- Copy the cleaned text from the output box.
When a blank line isn't blank
The most frustrating case is a line that looks empty and refuses to be removed. That happens because it holds a character which renders as nothing but still counts as content. Two are responsible for nearly every occurrence:
- Non-breaking space (U+00A0) — arrives with anything copied from a web page, since HTML uses it to prevent line wrapping. It looks exactly like a space and behaves nothing like one.
- Zero-width space (U+200B) — common in text pasted out of PDFs and word processors. It has no width at all, so a line containing one appears completely empty.
Drop whitespace-only catches ordinary spaces and tabs. For the invisible characters above, strip them first with find and replace, then clean the lines. If you want to see exactly which character is hiding there, the Unicode converter will name it by code point.
Why PDF and email text arrives broken
A PDF does not store paragraphs — it stores glyphs at coordinates. When you copy from one, the reader guesses where lines and breaks belong based on those positions, and inserts them at column edges, around images, and between any visually separated blocks. Email adds a different flavour of the same problem: quoted reply chains gain a blank line between every quoted line, so a long thread ends up double-spaced several times over.
In both cases the fix is the same — strip the empty lines, trim what remains, and you have text that can be pasted, searched, and compared normally again.
Keep indentation when it means something
Whitespace-only lines are usually noise, but not always. In Python, YAML, and Markdown code blocks, indentation carries meaning, and a blank-looking line inside an indented block may be deliberate. Turn Drop whitespace-only off and leave Trim lines off when cleaning source code, so only genuinely empty lines are touched.
Common uses
Tidying text copied from PDFs or emails, compacting double-spaced documents, cleaning a list before importing it, and removing the blank rows that appear when pasting a spreadsheet column. Cleaning a list often continues with remove duplicate lines and sort lines, which together turn pasted noise into an ordered, unique set.
Frequently asked questions
Does it remove whitespace-only lines?
By default yes — lines holding only spaces or tabs are treated as empty, which is almost always what you want since they look identical to blank lines on screen. Turn off 'Drop whitespace-only' when the indentation is meaningful, as it is in Python source or YAML, where a space-only line inside a block can still matter.
Why won't some blank-looking lines go away?
Because they aren't blank — they hold an invisible character that isn't a normal space. The usual culprits are the non-breaking space (U+00A0), which arrives with anything copied from a web page, and the zero-width space (U+200B), common in text pasted out of PDFs and rich documents. Both render as nothing but count as content. Turning on 'Drop whitespace-only' catches ordinary spaces and tabs; for the exotic ones, use find and replace to strip the character first.
What does 'Trim lines' do?
It removes leading and trailing spaces from the lines that survive, so the output has no ragged indentation. This is worth enabling for text pulled out of a PDF or an email, where lines often carry trailing spaces you can't see but which break later comparisons and sorting.
Why does text copied from a PDF have blank lines everywhere?
PDFs store positioned glyphs, not paragraphs. When you copy, the reader reconstructs lines from those positions and inserts a break wherever the layout suggested one — including at column edges, around images, and between visually separated blocks. The result is text broken at the wrong places with gaps between fragments, which is exactly what this tool is for.
Does it keep the order of my text?
Yes. Non-empty lines stay exactly where they were and are never reordered, merged, or altered beyond the optional trim. Only the blank lines between them are removed.
Can it collapse double spacing in a document?
Yes — pasting double-spaced text and removing empty lines returns compact, single-spaced text. This is the fastest way to undo the extra blank line that email clients add between every quoted line in a long reply chain.
Does it handle Windows and Mac line endings?
Yes. Text arrives with either CRLF (Windows) or LF (Unix and modern macOS) line breaks, and both are recognised as line boundaries, so a file saved on one platform and pasted on another still cleans correctly.
Is my text uploaded anywhere?
No. Everything runs in your browser with no upload, so your text never leaves your device — worth knowing when the text is an unpublished draft or an internal document.
Learn more
Related tools
Regex Tester
Test regular expressions with live match highlighting, groups, and replace.
Word Counter
Count words, characters, sentences, and reading time.
Case Converter
Convert text between upper, lower, title, camel, and snake case.
Character Counter
Count characters and stay under tweet, SMS, and meta tag limits — live.