Remove Extra Spaces

Collapses runs of repeated spaces into one and optionally trims the whitespace from the start and end of every line. It is the fix for text that came out of a PDF, a spreadsheet cell or a word processor carrying invisible padding.

Live demo · real result from this tool

Result

Too many spaces here. And here.

Processed on your device — nothing is uploaded.

How to use Remove Extra Spaces

  1. Paste the text you want to clean.
  2. Leave trim-lines ticked to remove leading and trailing whitespace on every line.
  3. Press the button and copy the cleaned text.
  4. Runs of two or more spaces become one; single spaces are left as they are.
  5. Line breaks and blank lines are preserved.
  6. A non-breaking space copied from a web page looks like a space but is a different character and is not collapsed — use find and replace for those.

Where the extra spaces come from

Copying out of a PDF is the usual culprit: PDFs position glyphs rather than storing words, so extraction tools insert spaces to approximate the gaps, and justified text produces several where there should be one. Spreadsheet cells accumulate trailing spaces from manual entry. Word processors leave double spaces after full stops — a typewriter convention that modern typesetting handles automatically and that now just looks like an error. Copying out of a chat or email client adds leading indentation from quoting.

Why it matters beyond tidiness

Trailing whitespace breaks exact comparisons silently: two lines that look identical do not match, deduplication misses copies, a spreadsheet lookup returns nothing, and a login fails because the username carries a space you cannot see. It also breaks CSV imports and makes diffs noisy. Cleaning whitespace before any comparison, import or deduplication step saves the ten minutes you would otherwise spend wondering why two identical things are not equal.

What it leaves alone

Single spaces between words are untouched, and line breaks are preserved — your paragraph structure survives. Tabs are not collapsed into spaces, since in code and in tab-separated data they are significant. Blank lines are kept as blank lines. If you need to collapse line breaks as well, or convert tabs, use the find and replace tool with a regular expression.

Frequently asked questions

What counts as extra spaces?
Two or more consecutive spaces are condensed to one. Leading/trailing spaces are trimmed.
Does this affect line breaks?
No — line breaks are preserved. Only horizontal space characters are affected.
Can I also trim each line?
Yes — enable 'Trim lines' to also remove leading and trailing spaces per line.
Will it remove my line breaks or paragraph spacing?
No. Only spaces within and around lines are affected; newlines are preserved, so paragraphs keep their structure.
Why are some double spaces still there afterwards?
Almost certainly non-breaking spaces (U+00A0) or another Unicode space character, which web pages and word processors insert and which look identical on screen. Use find and replace in regex mode with \u00a0 to convert them first.
Does it fix double spaces after a full stop?
Yes — those are just runs of two spaces and collapse to one. Single-spacing after a sentence is the standard in every current style guide; the double space is a leftover from monospaced typewriters.

Written by the ToolsRift team · Last updated

Pages are drafted with AI assistance and checked by automated tests. How we write and check pages.

Was this tool useful?

Report a problem

Start typing to search every tool.

↑ ↓ to moveEnter to openEsc to close