Remove empty lines from your text
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.
| Character | Code point | Where it comes from | Why it hurts |
|---|---|---|---|
| Non-breaking space | U+00A0 | Word, HTML , web pages | Not matched by a normal space search; breaks word wrap |
| Zero-width space | U+200B | Web copy, some CMSs | Completely invisible; splits words for search |
| Zero-width non-joiner | U+200C | Indic and Arabic text | Changes ligature rendering |
| Carriage return | U+000D | Windows files | Shows as ^M on Unix; doubles line counts |
| Line separator | U+2028 | Mac Word, InDesign | Breaks JSON and JavaScript strings |
| Byte order mark | U+FEFF | UTF-8 files from Excel | Corrupts the first field of a CSV |
| Soft hyphen | U+00AD | Justified PDF text | Invisible until the line wraps, then a hyphen appears |
| Narrow no-break space | U+202F | French typography | Same problems as U+00A0 |
| Tab | U+0009 | Spreadsheets | Reads as a column break in pasted data |
| Platform | Sequence | Written as |
|---|---|---|
| Unix, Linux, macOS (modern) | Line feed | \n — U+000A |
| Windows | Carriage return + line feed | \r\n |
| Classic Mac OS (pre-2001) | Carriage return only | \r |
| HTTP headers, SMTP | Carriage return + line feed | \r\n, required by the specs |
\r\n and lone \r to \n. Do this before anything else or your blank-line patterns will miss half the file.[ \t]+$.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.
cat -A on Linux marks tabs as ^I, line ends as $ and carriage returns as ^M.hexdump -C is the last word when you genuinely cannot tell what a byte is.[^\x00-\x7F] to highlight every non-ASCII character at once.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 ^$.
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.
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.
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.
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.
Short, exact answers to the questions people ask alongside this tool — the number first, then the working.
For teams, not just visitors
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.
Thanks — we have it, and you will get a reply from a person within one business day. Meanwhile every tool on SnoopTool stays free, with no signup.