Text Tools

How to Fix Messy Text Copied from PDFs and Websites

Paste text from a PDF and every line breaks in the wrong place; paste from a website and odd gaps appear. Here is what causes the mess and how to clean it fast.

In this article
  1. The usual problems
  2. Invisible characters: the hidden troublemakers
  3. How to clean text
  4. Rebuilding paragraphs from PDF text
  5. Other clean-up jobs
  6. Pasting without formatting
  7. Cleaning text for spreadsheets and forms
  8. For writers and students

The usual problems

  • Hard line breaks in the middle of sentences – PDFs store each printed line separately.
  • Double or triple spaces – from justified text or columns.
  • Several blank lines between paragraphs.
  • Invisible characters – non-breaking spaces, zero-width spaces and tabs that break searches, forms and code.
  • Spaces at the start or end of lines that make lists look ragged.
Whitespace RemoverRemove double spaces, tabs, blank lines, invisible characters and unwanted line breaks from any text. Perfect for text copied from PDFs and emails.
Open the free tool

Invisible characters: the hidden troublemakers

A non-breaking space looks exactly like a normal space but is a different character. Websites use it to stop words splitting across lines. When you paste text containing them into a form, a spreadsheet formula or code, matches fail mysteriously – “John Smith” does not equal “John Smith”. Zero-width spaces are even sneakier: they take up no room at all. Remove Extra Spaces converts or removes both.

How to clean text

  1. Paste your text into Remove Extra Spaces.
  2. Collapse multiple spaces into one and remove invisible characters.
  3. Choose to remove blank lines entirely or collapse them to a single blank line between paragraphs.
  4. For PDF text, choose “join into one line” to rebuild flowing paragraphs.
  5. Copy the clean text.

Rebuilding paragraphs from PDF text

Joining everything into one line fixes broken sentences but also merges paragraphs. A practical approach for longer documents:

  1. Keep blank lines collapsed to one – they mark paragraph breaks.
  2. Clean each paragraph by joining its lines.
  3. Or extract the PDF with PDF to Text, which already rebuilds lines and adds paragraph gaps based on the layout.

Other clean-up jobs

ProblemTool
Repeated header or footer textFind and Replace it with nothing
Hyphenated words split across lines (“informa- tion”)Find and Replace with regex: find (\w)- (\w), replace with $1$2
Text in ALL CAPSCase Converter → Sentence case
Duplicate lines in a listRemove Duplicate Lines

Pasting without formatting

Much of the mess comes with formatting – fonts, colours, links. Use “paste as plain text” to avoid it: Ctrl+Shift+V on Windows and Chromebooks, Cmd+Shift+Option+V on Mac in many apps (or Edit → Paste and Match Style). Then clean the spacing here.

Cleaning text for spreadsheets and forms

Names and codes pasted into spreadsheets often carry a trailing space that stops lookups such as VLOOKUP or XLOOKUP from finding a match. Clean the whole column here before pasting it back. The same applies to online forms that reject an email address or ID number “for no reason” – an invisible space is very often the culprit.

For writers and students

Before you count words or submit text into an online form, clean it. Double spaces and invisible characters can affect character counts and make your text look careless. Afterwards, check the length with the Word Counter.

Your text is processed in your browser and never uploaded.

Whitespace RemoverRemove double spaces, tabs, blank lines, invisible characters and unwanted line breaks from any text. Perfect for text copied from PDFs and emails.
Open the free tool
Keep reading

Related articles

All articles
Text

Find and Replace with Regular Expressions – A Beginner’s Guide

Plain find and replace changes one word to another. Regular expressions (regex) let you change patterns – every phone number, every date, every line start – in one go.

3 min read
Text

How to Clean Email, Phone Number and Keyword Lists in Seconds

Lists collected from several places always contain repeats. Sending to the same person twice or paying for duplicate keywords is avoidable – here is how.

3 min read
Text

How Long Should It Be? Word Counts for Essays, Articles, Speeches and Posts

“Write 1,500 words” is easy to say and hard to judge as you type. Here are typical lengths for common writing jobs and practical ways to hit a target.

3 min read