How to Clean Text Pasted from a PDF or Word Document
Hard line breaks, hyphenated words, curly quotes, non-breaking spaces and invisible characters — how to spot each problem and fix it in the right order.
Copying a paragraph out of a PDF and pasting it into a document, a CMS or an email almost never works cleanly the first time. Lines break in odd places, words are split with hyphens, quotation marks turn into question marks, and the text refuses to reflow. None of this is your fault: a PDF stores glyphs at coordinates, not sentences, so the copy operation reconstructs text that was never stored as text in the first place. Here is what actually goes wrong, and the order in which to fix it.
Problem 1: hard line breaks in the middle of sentences
A PDF has no concept of a paragraph that wraps. Each visual line usually copies as its own line, so the pasted result breaks after roughly every ten words and stops reflowing when you resize the window.
The fix: remove single line breaks while preserving the double breaks that separate real paragraphs. Doing it the other way round — stripping every break — welds paragraphs together and is much harder to undo. Our Remove Line Breaks tool keeps paragraph boundaries intact.
Problem 2: hyphenated words split across lines
Justified PDFs hyphenate at the right margin, so you get "conver-\ntible". After removing line breaks you are left with "conver- tible" or "conver-tible" mid-sentence.
The fix: search for a hyphen immediately followed by a line break and remove both, before you strip the remaining breaks. If you fix the breaks first, the hyphen loses its context and you cannot tell a line-break hyphen from a real one in "state-of-the-art".
Problem 3: smart quotes, em dashes and ligatures
Typeset documents use curly quotes, en and em dashes, and ligatures such as "fi" and "fl" that are single characters, not two letters. These paste fine into modern editors but break in code, in some CSV imports, and in older email clients, where they show up as question marks or as ’.
The fix: normalise to plain ASCII equivalents when the destination is technical, and keep the typographic characters when the destination is prose. Never do a blind find-and-replace of the apostrophe character without checking contractions first.
Problem 4: invisible characters
The worst offenders leave no visual trace: non-breaking spaces (U+00A0) that look like spaces but do not wrap, zero-width joiners, soft hyphens, and byte-order marks at the start of a file. They cause text that "looks right" to fail a comparison, break a search, or wrap strangely on mobile.
The fix: run the text through a plain-text pass that strips control and formatting characters and converts non-breaking spaces to ordinary ones. Our Plain Text Converter removes hidden formatting characters as well as rich-text styling.
Problem 5: inherited formatting from Word
Pasting from Word into a CMS often carries a payload of inline styles, class names and <span> wrappers. The visible text looks fine in the editor and then renders in the wrong font on the live site.
The fix: paste as plain text (Ctrl + Shift + V in most editors) or pass the text through a converter first, then apply the destination''s own styles. Reapplying bold and italics takes a minute; hunting down a stray inline font-family later takes much longer.
The order that works
Sequence matters more than the individual steps. This order avoids destroying information you still need:
- De-hyphenate words split across lines, while the line breaks are still there.
- Join lines within paragraphs, preserving blank lines between them.
- Strip hidden characters — non-breaking spaces, zero-width characters, BOM.
- Collapse whitespace — multiple spaces, tabs, and trailing spaces at line ends.
- Normalise punctuation only if the destination requires ASCII.
- Fix the case last, once sentence boundaries are reliable.
Fixing the case before joining lines is the most common mistake: a sentence-case pass sees each fragment as its own sentence and capitalises mid-sentence words.
Checking your work
Three quick checks catch almost everything:
- Resize the window. If the text does not reflow, line breaks remain.
- Search for two consecutive spaces. If you find any, the whitespace pass did not run.
- Paste a sample into a plain text editor. Anything that changes appearance was formatting, not text.
For long documents, a word and character count before and after is a fast sanity check — a large drop usually means a find-and-replace matched more than you intended.
Frequently asked questions
Why does copied PDF text sometimes come out as gibberish? The PDF may embed a subset font without a correct character map, so the copy operation returns the glyph indexes rather than letters. In that case no cleanup helps; the text must be re-extracted with OCR.
Is scanned-PDF text different? Yes. A scan is an image, so there is nothing to copy until OCR has run. OCR output has its own error profile — confused characters such as "l"/"1" and "0"/"O" — which spellcheck catches better than any cleanup tool.
Will cleaning text remove my bold and italics? A plain-text pass removes all styling by design. If you need to keep emphasis, clean the text first and reapply formatting in the destination, where it will use the correct styles.
Do these tools upload my document? Not here — every converter on this site runs in your browser, so confidential contracts and unpublished drafts never leave your device.
