PasteScrub
All toolsGuidesHow it worksAboutClean text
GuidesFixing weird spacing after copy and paste
Spacing problems

Fixing weird spacing after copy and paste

Updated August 4, 2026 · 5 min read

Remove extra spacesNormalize tabs, spaces, and blank rowsOpen the tool

Pasted text with uneven gaps is usually four different problems wearing the same disguise. Telling them apart matters, because the fix for one makes another worse.

Four causes, one symptom

Text pasted from a document, a web page, or a spreadsheet often arrives with spacing that looks subtly wrong. The visible symptom is the same in every case, but the cause is one of four things, and they need different handling.

1. Real double spaces from justified text

Justified text stretches the gaps between words so both margins align. That stretching is a rendering instruction, but when the text is extracted it frequently becomes two or three actual space characters.

This is the most common cause of ragged gaps in text copied from PDFs and formatted documents. It is also the easiest to fix: collapse runs of spaces down to one.

2. Tabs pretending to be spaces

Text from spreadsheets and code arrives with tab characters between fields. A tab renders as a variable-width gap depending on where it falls, so a column that lined up perfectly in the source looks arbitrary once pasted into prose.

Tabs need converting rather than collapsing. Turning each into a single space fixes prose; if the text is genuinely tabular, the tabs are the structure and removing them destroys it.

3. Non-breaking spaces

A non-breaking space (U+00A0) renders identically to a normal space but prevents a line break. HTML's   produces one, so text copied from web pages is full of them, and word processors insert them to stop awkward wraps.

These are the frustrating case: the text looks correct, but a find-and-replace searching for two spaces will not match a space followed by a non-breaking space, so cleanup silently misses them. They also break exact comparisons, CSV imports, and search.

If a spacing problem visibly persists after you have collapsed double spaces, non-breaking spaces are the most likely explanation. They have to be converted to ordinary spaces before any space-based cleanup can see them.

4. Line endings and blank lines

Windows ends lines with a carriage return and a line feed (CRLF); macOS and Linux use a line feed alone. Text moved between them can show a stray character at each line end, or double-spaced paragraphs where every line break has become two.

Separately, documents often contain empty paragraphs used as vertical spacing. Pasted into a different context they become blank lines, sometimes several in a row.

Fix them in the right order

The order matters, because each step can hide the next.

  1. 1
    Normalise line endings first

    Convert CRLF to LF so every later rule sees the same structure. Skipping this makes line-based cleanup behave inconsistently.

  2. 2
    Convert non-breaking and exotic spaces to ordinary spaces

    Do this before collapsing runs, or the collapse will step over them and leave the problem in place.

  3. 3
    Convert tabs, if the text is prose

    Skip this when the tabs are carrying real tabular structure.

  4. 4
    Collapse runs of spaces to one

    Now that everything is a normal space, this catches all of it.

  5. 5
    Trim trailing spaces and collapse blank lines last

    Doing this first would leave gaps that the earlier steps then reintroduce.

Applied in this order the result is deterministic. Applied in any other, cleanup tends to need several passes and still misses cases.

Fix it now

Collapse repeated spaces and tabs while preserving line breaks and readable paragraph spacing.

Good to know

Common questions

Justified text stretches the gaps between words to align both margins, and those visual gaps often extract as two or three real space characters.

Some of them are not two ordinary spaces. A space followed by a non-breaking space looks identical but does not match a search for two spaces.

Usually a line-ending mismatch — Windows CRLF read where a single line feed is expected — or empty paragraphs used as spacing in the source document.

Only if the text is prose. In tabular data the tabs are the column structure, and removing them destroys the alignment.

PasteScrub

Focused tools for cleaner text.
Fast, free, and private by design.

ToolsSmart cleanerPDF text cleanerRemove formattingRemove line breaksRemove duplicate linesAll 13 tools
CompanyGuidesAboutHow it worksContact
LegalPrivacyCookiesTermsAcceptable use
© 2026 PasteScrub Text processed on your deviceMade for less messy work