About this tool
Text copied from a PDF, a webpage, or someone else's document often carries extra spaces, inconsistent line breaks, or invisible characters that aren't obvious until they cause a problem — a broken layout, a failed string match, or garbled formatting when pasted elsewhere. This tool strips that out, all in your browser.
How to use the Text Cleaner
- Paste your text into the input box.
- Choose which cleanup options you want applied.
- Copy the cleaned result — it updates as you type or toggle options.
What each option does
- Collapse multiple spaces — turns runs of two or more spaces into a single space, common after copying from PDFs or justified text.
- Trim start/end of each line — removes leading and trailing whitespace from every line individually, without touching the spacing between words.
- Remove blank lines — deletes empty lines entirely, useful for collapsing an accidentally double-spaced paste into single-spaced text.
- Convert smart quotes to straight quotes — replaces curly "typographic" quotes and apostrophes (often introduced by word processors) with plain straight ones, which some code, forms, and older systems require.
- Line breaks — "Remove line breaks, keep paragraphs" joins the lines inside each paragraph with a single space but keeps the blank line between paragraphs; "Remove all line breaks" joins the whole text into one line.
- Remove invisible/zero-width characters — strips characters like zero-width spaces and byte-order marks that are invisible on screen but can break search, sorting, or form validation.
Remove extra spaces, blank lines, or every line break?
With the default options, pasted text like Hello world becomes Hello world, and any spaces left dangling at the start or end of a line are trimmed away. Tick Remove blank lines as well to close up empty lines between paragraphs, so double-spaced text comes out single-spaced.
By default the cleaner keeps every line break, so each line stays on its own line. To rejoin text that was split into short lines, change Line breaks to one of the remove options described in the next section.
How to remove line breaks from text copied from a PDF
PDFs store text as positioned lines, not as flowing paragraphs, so copying from a PDF usually puts a hard line break at the end of every visual line. Pasted into an email or a form, the text then breaks in odd places. Choose Remove line breaks, keep paragraphs to fix it: within each paragraph, every line break (and any spaces around it) becomes one space, while a blank line still separates paragraphs. Windows line endings (CR LF) are handled the same way as plain LF.
For example, this pasted text:
This sentence was split by a PDF into short lines. Second paragraph starts here.
becomes two clean paragraphs: This sentence was split by a PDF into short lines. and Second paragraph starts here., still separated by a blank line. With Remove all line breaks it becomes a single line: This sentence was split by a PDF into short lines. Second paragraph starts here. If you also tick Remove blank lines, the keep-paragraphs mode gives one paragraph per line, which is handy for pasting into a spreadsheet column.
One limit to know: a word that the PDF hyphenated across two lines (such as exam- at the end of one line and ple on the next) is joined as exam- ple. The tool cannot tell a line-end hyphen from a real one like well-known, so it leaves hyphens alone; fix those few by hand or with Find & Replace.
Common use cases
- Cleaning up text copied from a PDF before pasting it into an editor or CMS
- Removing Word's smart quotes before pasting text into code or a plain-text form
- Fixing a block of text with inconsistent, extra, or doubled-up spacing
- Stripping invisible characters that are silently breaking a form submission or search match
Things to watch out for
"Collapse multiple spaces" and "Trim start/end of each line" both operate per line, so intentional formatting like a Markdown code block's leading spaces will also be flattened — turn those two off if you're cleaning up code or anything with meaningful indentation. Converting smart quotes is one-directional here (curly to straight); if you need straight quotes converted back to nice typographic quotes for a publication, that's a different, more context-dependent transformation this tool doesn't attempt.
Exactly which characters are changed
Hidden characters are hard to talk about because you can't see them, so here are the precise Unicode code points each option looks for.
| Option | Characters affected | Replaced with |
|---|---|---|
| Remove invisible characters | U+200B zero width space, U+200C zero width non-joiner, U+200D zero width joiner, U+FEFF byte order mark, U+00AD soft hyphen | Nothing (deleted) |
| Smart quotes to straight | U+2018 and U+2019 (curly single quotes and apostrophe) | U+0027 ' |
| Smart quotes to straight | U+201C and U+201D (curly double quotes) | U+0022 " |
| Collapse multiple spaces | Two or more ordinary spaces (U+0020) in a row | One space |
The options run in a fixed order: invisible characters first, then quotes, then line trimming, then space collapsing, and finally blank-line removal. So a line that contains only a zero width space counts as blank once the invisible character is gone.
What it deliberately leaves alone
- Tabs and non-breaking spaces inside a line. Collapse multiple spaces matches only the ordinary space character. A run of tabs, or the non-breaking spaces (U+00A0) that web pages and word processors often insert, stays as it is in the middle of a line. Trim start/end of each line does remove them at the start and end of lines, because trimming covers all whitespace. To replace non-breaking spaces everywhere, use Find & Replace with regex on and find
\u00A0. - Other quote styles. Low quotes such as „ and ‚, guillemets « », and prime marks ′ ″ are not changed.
- Your words. The tool never changes letters, spelling or case. For capitalization, use the Case Converter; for repeated lines, the Duplicate Remover.
When removing invisible characters can change text
Most zero-width characters in pasted text are accidental, but two of them do real work in some content. The zero width joiner glues emoji together into a single picture: many family, profession and flag-style emoji are several emoji joined with U+200D, and removing the joiners splits them back into separate symbols. The zero width non-joiner is part of normal spelling in some scripts, including Persian and several Indian languages, where it controls how letters connect. If your text contains emoji sequences or those scripts, turn the invisible-character option off. Soft hyphens are safe to remove: they only mark where a word may break at the end of a line.
Frequently asked questions
Paste the text and keep the Remove invisible/zero-width characters option on. It deletes zero width spaces (U+200B) along with zero width joiners and non-joiners, byte order marks and soft hyphens. The result looks identical on screen but no longer contains the hidden characters that break searches, string comparisons and form validation.
Only at the start and end of lines, when Trim start/end of each line is on. Collapse multiple spaces matches ordinary spaces only, so non-breaking spaces (U+00A0) inside a line stay. To replace them everywhere, use Find and Replace with regex turned on, searching for \u00A0 and replacing it with a normal space.
Many emoji, such as family groups, are several emoji joined by an invisible zero width joiner character. The Remove invisible characters option deletes that joiner, so the combined emoji falls apart into its separate pieces. Turn that option off when cleaning text that contains emoji and your other settings will still apply.
Set Line breaks to Remove line breaks, keep paragraphs. Lines inside a paragraph are joined with a single space, and a blank line between paragraphs is kept. This is the usual fix for text copied from a PDF, where every visual line ends with a hard line break.
Set Line breaks to Remove all line breaks. Every line break, including the blank lines between paragraphs, is replaced by a single space and the result is trimmed, so the whole text comes out as one line. Leading and trailing spaces around each break are absorbed too.