Clean Up Text — Extra Spaces, Blank Lines and Broken Lines
Strip the extra spaces, blank lines and invisible characters out of text copied from a PDF or an email
Your data stays with you. Conversion happens inside the browser; nothing is sent to a server.
Did this tool do the job?
Thanks, your feedback came through.
How it works
Paste the text into the left box; the result appears on the right as you type. Text copied out of a PDF almost always arrives the same way: every line is cut at the width of the page, words are separated by two or three spaces, and three blank lines sit between paragraphs. Set 'Broken lines' to 'Join' and every line that does not end in a full stop, question mark, colon or similar punctuation is joined to the one below it, so the paragraphs flow again. Words split across a line with a hyphen (hy- / phen) are rejoined and the hyphen is dropped. With text copied from a web page the real problem is what you cannot see: zero-width spaces, soft hyphens and non-breaking spaces leave no mark on screen but break search and paste-into-a-spreadsheet; the 'Invisible characters' setting clears them out. The status line spells out what happened — how many blank lines went, how many double spaces collapsed, how many invisible characters were removed — and says so plainly when nothing changed at all. Copy the clean text with one click or download it as a text file.
This tool is also known as clean text online, remove extra spaces from text, remove blank lines, fix line breaks from pdf, remove zero width characters, text cleaner.
What is Invisible characters (zero-width space, BOM, soft hyphen)?
Invisible characters take up a position in a string but draw nothing on screen. The common ones are the zero-width space (U+200B), the soft hyphen (U+00AD), the byte order mark or BOM (U+FEFF), the word joiner (U+2060) and the bidirectional control characters (U+202A-U+202E). They slip into text copied from web pages, word processors and machine-generated exports. The damage never shows up visually, only functionally: a search returns nothing, two identical-looking rows count as different, and the first column header of a CSV is not recognised by the spreadsheet that reads it.
What is Non-breaking space (NBSP)?
A non-breaking space sits between words like an ordinary space but forbids a line break at that point (U+00A0). Web pages use it to keep a number attached to its unit, so that '5 kg' never splits across two lines. On screen it is indistinguishable from a normal space, but to a computer it is a different character: a find-and-replace looking for a normal space will not match it, a text-to-columns split will not break there, and a spreadsheet will read the number as text. That is why cleaning converts it to a normal space instead of deleting it.
What is Broken line (hard wrap)?
A broken line is a real line-break character that has landed in the middle of a sentence. It is typical of PDF and plain-text email: a PDF splits the page into visual lines and plain-text mail wraps at 72 to 78 characters, and copying turns those visual splits into permanent line breaks. Paste the result into a word processor or a web page and the paragraph will not reflow — the lines stay stepped like a staircase. The decision to rejoin is made from punctuation: if a line does not end with a full stop, exclamation mark, question mark or colon, the sentence is still running.
How is cleaning text different from find and replace?
Cleaning works without you naming anything: it fixes faults in the shape of the text — spaces, line breaks, invisible characters — by rule, and never touches the words. Find and Replace is the opposite: you say what turns into what, and the tool edits the content rather than the shape. The useful order is almost always clean first, replace second. Search misses things in dirty text: if a zero-width space sits inside 'Berlin', a search for Berlin will not find that line and nothing on screen tells you why. Once the invisible characters are gone, the search behaves the way you expect it to.
What do characters you cannot see actually break?
Copied text often carries characters that occupy space without leaving any mark. A zero-width space (U+200B) splits a word invisibly: a cell reading 'Berlin' is not found by a search for Berlin, and two lines that look identical compare as different. A soft hyphen (U+00AD) marks where a word may break and only shows up if it lands at the end of a line. A BOM (U+FEFF) sticks to the very start of a file and corrupts the first column name of a CSV. Direction control characters (U+202A-U+202E) can even display part of a line backwards.
This tool deletes those characters, but converts the non-breaking space (U+00A0) instead of deleting it — a non-breaking space is a visible space, and removing it would glue words together. The zero-width joiner (U+200D) is deliberately preserved: it is the character that holds family and profession emoji together, and deleting it would scatter one emoji into three.
Which setting for which job?
The six settings work independently; leave off whatever does not apply. The defaults cover the most common job — tidying up copied prose. Joining broken lines starts switched off on purpose: in verse, address lists and code, a line ending carries meaning.
- Contract or article copied from a PDF → join broken lines + collapse blank lines
- Table data copied from a web page → remove invisible characters + trim line ends
- Poetry, address lists, source code → broken line joining off, trimming off
- Text out of Word with curly quotes → straighten smart quotes and dashes
- Thinning out two lists pasted on top of each other → remove all blank lines
Frequently asked questions
Why is text copied from a PDF cut off at every line?
A PDF lays out lines to fit the page, so copying turns each visual line into a real line break. Set 'Broken lines' to 'Join': lines that do not end in punctuation are merged with the next one and the paragraph comes back.
How do I know my text contains an invisible character?
The usual symptom is that two lines look identical on screen but a search or a comparison treats them as different. Clean the text with 'Invisible characters' on; the status line reports how many were found, and says nothing when there were none.
Does this change the capitalisation of my text?
No. Letters are never touched — only spaces, line breaks, invisible characters and, if you switch it on, typographic quotes and dashes. Upper and lower case come through exactly as you pasted them.
Can I keep my indentation?
Yes. Set 'Spaces at the start and end of a line' to 'Leave alone' and leading indentation survives. When cleaning code or verse you will usually want to switch the repeated-space setting off as well.
Is my text sent anywhere?
No. Cleaning runs entirely inside your browser; the text never leaves this page and is not sent to any server or third party.