How to clean up text pasted into Google Docs
Text pasted from a PDF or an email often arrives with line breaks in the middle of sentences, doubled spaces, stray tabs and odd characters you cannot see. Google Docs can fix most of this with built-in find and replace and a few regular expressions. Always work on a copy.
Why this is harder than it looks
PDFs and emails wrap lines by inserting a break at each line end, so the paragraphs in Docs stay chopped up and reflow badly. Invisible characters such as non-breaking spaces and zero-width marks break searching and justification. Fixing each by hand across a long document takes ages and invites errors.
Step by step
- Paste cleanly first. Use Edit > Paste without formatting, or Ctrl+Shift+V (Cmd+Shift+V on Mac), to drop the source fonts and colors. Then select the text and choose Format > Clear formatting (Ctrl+\) to remove leftover mixed fonts and sizes. Make a copy through File > Make a copy before bulk replacements.
- Open regex find and replace. Press Ctrl+H (Cmd+Shift+H on Mac), tick Match using regular expressions, and run each pattern with Replace all. Docs uses RE2 syntax, so features such as lookbehind are not available. Use the Previous and Next buttons first to check what a pattern matches.
- Collapse double spaces and tabs. Search for two or more spaces with the pattern ' {2,}' and replace with a single space. For tabs inside body text search '\t+' and replace with one space. Avoid touching tabs you use for alignment in tables or indents, and test on a selection first.
- Remove invisible characters. Replace non-breaking spaces by searching '\x{00A0}' and replacing with a normal space. For zero-width characters search '[\x{200B}\x{200C}\x{200D}\x{FEFF}]' and replace with nothing. These often come from web pages and PDFs and silently break search and word counts.
- Join hard-wrapped lines. Search '([a-z,])\n([a-z])' and replace with '$1 $2'. Lines ending in a lowercase letter or comma and continuing with lowercase are almost certainly wrapped mid-sentence. Real paragraph ends, which finish with a period or are followed by a capital, stay. For words split with a hyphen at line end, use '([a-z])-\n([a-z])' replaced by '$1$2', then check genuine compounds.
- Fix quotes and bullets. To straighten smart quotes, search '[“”]' and replace with a straight double quote, and '[‘’]' with a straight apostrophe. For fake bullets such as a pasted bullet character followed by text, remove the character and apply Format > Bullets & numbering > Bulleted list. Rebuild broken numbering the same way.
- Review the result. Scan the document for merged paragraphs, lost headings and altered hyphenated words. Check names, tables and code, which may rely on exact spacing. Use Edit > Undo or version history through File > Version history if a pattern did more damage than expected.
Common mistakes
- Running replacements on the original instead of a copy
- Joining all line breaks, which merges real paragraphs and headings
- Removing hyphens at line ends and breaking real compounds
- Forgetting to tick Match using regular expressions
Where PasteRepair Pro fits in
PasteRepair Pro is a Google Docs add-on that fixes text damaged by paste: hard line wraps, double spaces, broken bullets and numbering, smart quotes, stray tabs, non-breaking spaces, zero-width characters and mixed fonts. It always shows a preview of changes before applying, and works on a selection or the whole document. It is built but not listed in any store.
PasteRepair Pro support and FAQ
FAQ
PDFs store text as positioned lines, not paragraphs. When you copy, each visual line ends with a break, so Docs keeps the chopped layout. You have to join those lines back together.
Yes, with regular expressions. Turn on Match using regular expressions, then search for codes such as \x{00A0} for non-breaking spaces or \x{200B} for zero-width spaces, and replace them.
Not always. Many line-end hyphens are soft breaks, but some belong to real compounds such as well-known. Use the pattern, then search the result for suspicious joined words.