Blank Line Remover

Remove empty lines from your text

Input Text

Output

How Does the Blank Line Remover Work?

Paste your text and choose between removing all blank lines entirely or reducing multiple consecutive blank lines to a single one. The "Trim Trailing Spaces" option removes unnecessary whitespace at the end of each line. The tool reports how many lines were removed, helping you quickly clean up text from emails, code, documents, or web content.

Frequently Asked Questions

What does remove all blank lines do?
It removes every empty line from your text, leaving only lines that contain actual content.
What does reduce to single blank line mean?
Multiple consecutive blank lines are collapsed into a single blank line, preserving paragraph spacing while removing excessive gaps.
What does trim trailing spaces do?
It removes whitespace characters (spaces and tabs) from the end of each line.

Related Tools

Cleaning up whitespace in pasted text

The usual culprit in text pasted from a PDF or Word is not the blank lines — it is invisible characters. Non-breaking spaces, zero-width spaces and Windows carriage returns all survive a copy-paste and all look identical to nothing at all, which is why a manual clean never quite works.

The invisible characters that cause trouble

CharacterCode pointWhere it comes fromWhy it hurts
Non-breaking spaceU+00A0Word, HTML  , web pagesNot matched by a normal space search; breaks word wrap
Zero-width spaceU+200BWeb copy, some CMSsCompletely invisible; splits words for search
Zero-width non-joinerU+200CIndic and Arabic textChanges ligature rendering
Carriage returnU+000DWindows filesShows as ^M on Unix; doubles line counts
Line separatorU+2028Mac Word, InDesignBreaks JSON and JavaScript strings
Byte order markU+FEFFUTF-8 files from ExcelCorrupts the first field of a CSV
Soft hyphenU+00ADJustified PDF textInvisible until the line wraps, then a hyphen appears
Narrow no-break spaceU+202FFrench typographySame problems as U+00A0
TabU+0009SpreadsheetsReads as a column break in pasted data

Line endings by platform

PlatformSequenceWritten as
Unix, Linux, macOS (modern)Line feed\n — U+000A
WindowsCarriage return + line feed\r\n
Classic Mac OS (pre-2001)Carriage return only\r
HTTP headers, SMTPCarriage return + line feed\r\n, required by the specs

A cleaning order that works

  1. Normalise line endings first. Convert every \r\n and lone \r to \n. Do this before anything else or your blank-line patterns will miss half the file.
  2. Replace exotic spaces with ordinary ones — U+00A0, U+202F, U+2007, U+2009 and friends.
  3. Delete truly zero-width characters — U+200B, U+200C, U+200D, U+FEFF, U+00AD. Be careful with U+200C and U+200D if the text is Indic or Arabic, where they are meaningful.
  4. Strip trailing whitespace from every line: [ \t]+$.
  5. Collapse runs of blank lines to at most one, rather than removing them all — paragraph breaks usually carry meaning.
  6. Only then collapse multiple spaces inside lines, if that is what you want.

Fixing PDF paste specifically

Text copied out of a PDF arrives with a hard line break at the end of every visual line, because a PDF has no paragraphs — only positioned glyphs. The fix is not to remove all newlines but to rejoin lines that were broken mid-sentence: replace a newline that follows a lowercase letter or a comma with a single space, while leaving a newline that follows a full stop alone. Watch for soft hyphens too: a word split as "infor-\nmation" needs the hyphen and the newline both removed, not just the newline.

How to see what is actually in your text

More questions people ask

Why does my text still have blank lines after I removed them?

Almost always because the file uses Windows line endings and your pattern only matched \n, or because the "blank" lines contain spaces, tabs or non-breaking spaces. Normalise line endings first, then match ^\s*$ rather than ^$.

What is a non-breaking space and how do I remove it?

It is the character U+00A0, produced by   in HTML and inserted automatically by Word. It looks exactly like a space but is not matched by a space in search. Replace the character U+00A0 explicitly with an ordinary space.

Why does text copied from a PDF break at every line?

A PDF stores positioned glyphs, not paragraphs, so copying inserts a hard break at the end of each visual line. To rejoin, replace a newline that follows a lowercase letter or comma with a space, and leave newlines after full stops alone.

What is a byte order mark and why does it break my CSV?

The BOM is the invisible character U+FEFF that some tools, notably Excel, write at the start of a UTF-8 file. Parsers that do not strip it read it as part of the first column heading, so a field named "id" becomes something that never matches.

Should I remove all blank lines or just duplicates?

Usually just duplicates. A single blank line is a paragraph break and carries meaning; runs of three or more are formatting debris. Collapsing to at most one blank line preserves structure while cleaning the noise.

Everything on this page runs in your browser — nothing you type is uploaded or stored.

Answers, not just a number

Short, exact answers to the questions people ask alongside this tool — the number first, then the working.

For teams, not just visitors

Want this calculator on your own site?

We build the calculators on SnoopTool as embeddable widgets in your branding, wired to your own lead form — the same maths, your colours, your domain, your leads. Tell us which one and we will send back a working demo you can put in front of your team.

One reply from a person, within one business day. No newsletter, no sequence. See our privacy policy.

Copied to clipboard!