How to Clean Up Text Pasted from PDFs, Emails and Web Pages
Text copied from a PDF, an email or a web page comes with broken lines, stray spaces and hidden characters. This workflow fixes each problem in turn, in a few minutes, with no retyping.

Key takeaways
- Pasted text breaks in five ways: a hard line break at the end of every line, double or non-breaking spaces, smart quotes and odd dashes, repeated lines, and invisible characters.
- Work in a fixed order. Strip formatting, join lines, collapse spaces, remove duplicates, then fix quotes and dashes. Each step makes the next one easier.
- To keep paragraphs when you join lines, treat a blank line as a paragraph break and a single line break as a space.
- Non-breaking spaces, zero-width spaces and soft hyphens look like nothing, but they break search, sorting and alignment. A whitespace tool that fixes them is the only reliable cure.
- Paste through a plain text converter when the text is going into a form, a CMS or code. Keep a copy of the original before you clean it.
Text copied from a PDF, an email or a web page usually needs five fixes. Remove the hard line break at the end of each line. Collapse double spaces and non-breaking spaces. Strip the formatting that came with the text. Delete repeated lines. Swap smart quotes and odd dashes for plain ones. Do them in that order. It takes a couple of minutes with the right tools, and you do not have to retype anything.
Why pasted text comes out wrong
Each source breaks text for its own reasons. Know the reason and you know which fix to use.
PDFs do not store paragraphs. They store small pieces of text, each in a fixed place on the page. When you copy, the reader joins the pieces line by line. It has to guess where each line ends. So you get a line break at the end of every printed line. Words split at the margin keep a hyphen in the middle. Sometimes two columns get mixed together. PDFs made from print can also hold ligatures. A ligature is one character that stands for "fi" or "fl". It looks right but fails in search.
Emails wrap at a fixed width, usually 72 or 76 characters. This is most common in replies and forwarded mail. Quoted lines start with a greater-than sign. Signatures, legal notes and lines like "On Monday, X wrote:" come along too. HTML emails also add non-breaking spaces wherever the designer wanted to stop a line from wrapping.
Web pages bring hidden extras. A copied paragraph can include image captions, "Share" buttons, the alt text of icons and the text of collapsed sections. Paste rich text into a word processor and it keeps the fonts, colours and link styles of the page. Paste it into a plain field and the links are gone. The non-breaking spaces and zero-width characters stay, because web designers use them a lot.
Word processors and chat apps swap straight quotes for curly ones. They turn two hyphens into an em dash and three dots into one ellipsis character. That looks nicer in a document. But it causes trouble in code, spreadsheets and SMS, and in any system that compares text exactly.
The invisible characters
Most cleanup problems come from characters you cannot see. These cause the most confusion.
| Character | Code point | Where it comes from | What it breaks |
|---|---|---|---|
| Non-breaking space | U+00A0 | HTML, Word, French typography | Phrase search fails; columns misalign; double spaces will not collapse |
| Zero-width space | U+200B | Web pages, some keyboards | Words look joined but count as two; Find cannot see it |
| Soft hyphen | U+00AD | Justified web text, PDFs | Words split at odd places when text wraps; hidden in search |
| Byte order mark | U+FEFF | Start of exported files | A blank character before the first word; breaks CSV imports |
| Tab | U+0009 | Tables, code, PDFs | Shows as a gap of varying width; becomes a jump in spreadsheets |
| Carriage return | U+000D | Windows line endings | Shows as a double line break or "^M" on other systems |
| Ligature fi | U+FB01 | PDFs from print | "find" becomes "find" and every search for "find" fails |
| Curly quotes | U+2018, U+2019, U+201C, U+201D | Word, Google Docs, phones | Code will not run; exact matches fail; SMS costs double |
| En and em dash | U+2013, U+2014 | Word, Google Docs | Fine in prose; wrong in filenames, code and number ranges |
The non-breaking space is by far the most common. It looks exactly like a space. So a search for two spaces finds nothing. A spreadsheet also sees "John Smith" with a non-breaking space as a different value from "John Smith" with a normal space. If a column will not sort, or a duplicate check misses obvious duplicates, suspect this character first.

The workflow, step by step
The order matters, for three reasons. Stripping formatting first removes hidden characters that would break the later steps. Joining lines before you collapse spaces means the spaces made by the join get collapsed too. Removing duplicates after the spaces are tidy means lines that differ only by a trailing space are seen as the same.
- Save the original. Paste it into a notepad or a scratch document before you change anything. Cleanup cannot be undone. The one time you need the original is the one time you did not keep it.
- Strip formatting. Paste into the Plain Text Converter. It throws away fonts, colours, links, bold, italic and HTML tags. It also removes the styled Unicode letters that fancy-text generators make. Only the plain characters are left. It also removes the byte order mark and most zero-width characters.
- Join the broken lines. Run the text through Remove Line Breaks. Choose the option that keeps paragraph breaks. A blank line then stays as a paragraph break, and every single line break becomes a space. For a PDF, also fix the hyphens at line ends, so "informa- tion" becomes "information". Watch for words that really have a hyphen, such as "well-known". Those should keep it.
- Collapse whitespace. The Whitespace Remover does four jobs. It turns non-breaking spaces and tabs into normal spaces. It cuts any run of spaces down to one. It trims spaces from the start and end of each line. It removes extra blank lines. Do this after you join the lines, so the spaces made in step three are included.
- Remove repeated lines. Is the text a list, a log, an export or a set of addresses? Then the Duplicate Line Remover deletes each repeated line and keeps the first one. Use the case-insensitive option if "Smith" and "smith" are the same entry. Use the trim option too, so trailing spaces do not hide duplicates.
- Normalise quotes and dashes. Replace curly quotes with straight ones. Replace em dashes with hyphens, or with spaced hyphens. Do this if the text is going into code, a spreadsheet, a filename or an SMS. Leave them alone if the text is prose for a document or a website, where they are correct.
- Read it once. Look for mixed columns, captions in the middle of a paragraph, and a hyphen removed from a word that needed it. No tool catches these.
Is the text going into a web form or a CMS (a website editor)? Paste the clean version with the plain-paste shortcut. That is Ctrl+Shift+V on Windows and Linux, and Cmd+Shift+V in most Mac apps. It stops the editor from bringing back formatting from the clipboard.
A worked example from a PDF
Here is a paragraph as it arrives from a two-column PDF report. The invisible characters are shown in brackets.
The survey covered 1,240 small busi-
nesses across the United King-
dom.[NBSP][NBSP]Of these, 61% reported
that cash flow was their main con-
cern, up from 54% in the previ-
ous year.
Table 2: Main concerns by sector
Table 2: Main concerns by sector
Respondents in retail were the
most likely to cite cash flow.
Step two, strip formatting, changes nothing you can see here. It only removes hidden styling. Step three joins the lines and repairs the hyphens. This gives one paragraph: "The survey covered 1,240 small businesses across the United Kingdom.[NBSP][NBSP]Of these, 61% reported that cash flow was their main concern, up from 54% in the previous year." The blank line before "Table 2" stays, so the caption stays separate. Step four turns the two non-breaking spaces into one normal space. Step five removes the second "Table 2" line. The PDF showed that caption twice. Step seven is the read-through. Here you notice that "United Kingdom" was split at "King-". You check that it joined properly, and it did. The whole process took four pastes.
Before, the text was 11 lines with 2 non-breaking spaces, 4 false hyphens and 1 duplicate. After, it is 3 lines with none of them. A search for "businesses" now finds the word.

What each cleanup tool does, and does not do
The tools overlap. That is confusing until you know the one job each tool is for.
| Tool | Best for | Leaves alone |
|---|---|---|
| Plain Text Converter | Rich text, HTML, styled Unicode letters, hidden characters | Line breaks, spacing, duplicates |
| Remove Line Breaks | Hard-wrapped PDF and email text; can keep paragraphs and fix hyphens | Runs of spaces, quotes, duplicates |
| Whitespace Remover | Double spaces, tabs, non-breaking spaces, spaces at line ends, stacked blank lines | Single line breaks, formatting, quotes |
| Duplicate Line Remover | Lists, exports, logs, addresses, keyword lists | Everything inside a line |
| Remove Text Formatting | Fancy Unicode fonts, HTML tags, smart quotes and dashes in one pass | Line structure and spacing |
Two of them are easy to mix up. The Plain Text Converter is the general first step. It takes whatever is on the clipboard and reduces it to plain characters. Remove Text Formatting is more specific. It targets styled Unicode letters, leftover HTML tags and typographic quotes. Pick it when text comes from a social media post or a web page. You get straight quotes and plain letters in one pass, and the lines stay as they are.
No tool reads for meaning. It cannot know that a line break before "Dear Sir" was on purpose. It cannot know that a repeated line is a chorus, not a mistake. It cannot know that an en dash in "pages 10–12" should stay. That is what the final read-through is for.
Special cases
Email replies and quoted text
Quoted lines start with "> ". Nested replies stack several of them. First remove the prefixes. Use find-and-replace on "> " at the start of a line. Then run the standard workflow. Delete signatures and legal notes by hand. Every company formats them in its own way, so they are hard to automate.
Two-column PDFs
Sometimes lines from the two columns are mixed together. No line-joining tool can pull them apart. The facts about which column a line came from are gone. Instead, copy one column at a time from the PDF reader. Most readers have a column-select mode, or you can drag a narrow selection. Then clean each half on its own.
Tables from PDFs and web pages
A copied table arrives in one of two ways. It may be tab-separated lines, which paste neatly into a spreadsheet. Or it may be one value per line, which does not. In the second case, paste into the spreadsheet first and use its text-to-columns feature. Do not try to rebuild the rows in a text tool. Run the whitespace step before you paste. Non-breaking spaces inside cells stop number columns from being read as numbers.
Code and configuration
Code pasted from a web page or a chat app often has problems. It may have curly quotes, non-breaking spaces in the indents, or an em dash where two hyphens were meant. Each one causes a syntax error that you cannot see in the editor. Strip the formatting first. Then normalise quotes and dashes. If the language cares about indents, make all of them tabs or all of them spaces.
Cleaning text from a password manager, a licence key or a one-time code often breaks it. These are not prose. A hyphen or a run of spaces inside them may matter. Clean around them, not through them.
Where to go next
Start with the Plain Text Converter for anything copied from a document or web page. Follow it with Remove Line Breaks and the Whitespace Remover for PDF and email text. Finish with the Duplicate Line Remover for lists. Each one is linked in the workflow above. Every tool runs in your browser. Nothing you paste is uploaded.
Frequently asked questions
How do I remove line breaks from text copied from a PDF?
Paste the text into a line-break removal tool. Choose the option that keeps paragraph breaks. The tool treats a blank line as the end of a paragraph and turns every other line break into a space. The wrapped lines then flow together again. Turn on hyphen repair if the tool has it, so words split at the margin are joined. Then read through once. A word such as "well-known" may need its hyphen put back.
Why will my double spaces not go away with find and replace?
One of the spaces is almost certainly a non-breaking space, code point U+00A0. It looks the same as a normal space, but it is a different character. Find and replace for two ordinary spaces does not match it. HTML pages and Word documents add these spaces to stop lines wrapping in bad places. A whitespace tool turns them into normal spaces, then cuts runs of spaces down to one. That fixes it in one pass.
What is the difference between smart quotes and straight quotes?
Straight quotes are the plain apostrophe and double quote on your keyboard. Smart or curly quotes are separate characters, with different opening and closing shapes. Word processors and phones swap them in on their own. They look better in printed prose. But they break code, exact searches and some forms. One curly quote also forces an SMS into 16-bit encoding, which halves its size. Switch to straight quotes for code, spreadsheets, filenames and text messages.
Does pasting as plain text remove hidden characters?
It removes formatting such as fonts, bold and links, but not every hidden character. Non-breaking spaces, zero-width spaces and soft hyphens are characters, not formatting. So plain paste keeps them. The same goes for curly quotes and styled Unicode letters. You need a plain text converter or whitespace tool to remove them. Plain paste is still a good first step, because it stops the editor from importing styles from the clipboard.
How do I remove duplicate lines from a list?
Paste the list into a duplicate line remover. It deletes every repeated line and keeps the first one. Before you do, collapse the whitespace, so lines that differ only by a trailing space are seen as duplicates. Use the case-insensitive option if entries such as "Smith" and "smith" are the same. In a spreadsheet, a non-breaking space inside a cell is the usual reason two identical-looking entries are not found.
In what order should I clean up pasted text?
Strip formatting first. Join broken lines second. Collapse whitespace third. Remove duplicate lines fourth. Fix quotes and dashes last. Each step prepares the next. Removing formatting clears hidden characters that would confuse the line joiner. Joining lines makes spaces that the whitespace step then collapses. Tidy whitespace lets the duplicate check match lines that differ only by trailing spaces. Keep a copy of the original and read the result once at the end.
Try the tools from this guide
Related guides
Bold and Italic Text on Social Media: How It Works and When to Avoid It
The bold and italic text in bios and posts is not real formatting. It is a set of Unicode symbols borrowed from maths. Learn how it works, where it breaks and when to skip it.
Read the guideCharacter Limits for Social Media, SMS and SEO in 2026
Every platform cuts text off somewhere. This reference lists the limits for X, Instagram, LinkedIn, TikTok, YouTube, SMS and Google search snippets, and explains how to write right up to them.
Read the guideHow Word Counters Count: Words, Characters and Reading Time
Word, Google Docs and online counters rarely agree to the word. This guide explains what each one counts, why hyphens and emoji cause trouble, and how reading time is worked out.
Read the guide

