~ / text / remove-spaces

␣ Remove Extra Spaces

Collapse double spaces into one, remove every space, or just trim the start and end of each line. Catches invisible characters like non-breaking and zero-width spaces too.

options
Mode
Also treat as spaces
Lines
output

How to remove extra spaces

  1. Paste your text into the input box. Right below it you'll see which kinds of whitespace it contains and how many.
  2. Choose a mode. The cleaned text appears in the output box immediately, with character counts before and after.
  3. Press copy to grab the result, or use as input to run it through a different mode.

The three modes

ModeInputOutputGood for
Multiple spaces → oneHello   worldHello worldText pasted from web pages, PDFs or emails; fixing double spaces after periods
Remove all spaces4111 1111 1111 11114111111111111111Card, account, phone and tracking numbers; codes and keys
Trim leading/trailing only  Title  TitleSpreadsheet cells and lists with stray indentation or trailing spaces

"Remove all spaces" keeps line breaks by default. To join everything onto a single line, turn on Remove line breaks too, or use the line break remover, which joins lines with a space so words don't run together.

Invisible whitespace characters

Text copied from websites, PDFs, chat apps and word processors often contains characters that look like a normal space (U+0020) but aren't. They're the reason an Excel VLOOKUP fails, code won't compile, or a search can't find a word that's clearly there.

In a regular expression the same cleanup looks like /[ \t\u00A0\u3000]+/g. Want to experiment with patterns? Try the regex tester.

Common uses

Everything runs in your browser — nothing is uploaded. Removing all spaces from normal sentences makes them unreadable, so for prose use "Multiple spaces → one".

FAQ

How do I remove double spaces after periods?
Paste your text and keep the default "Multiple spaces → one" mode. Every run of two or more spaces becomes a single space, including the double space after a period.
Why does Excel TRIM not remove some spaces?
Excel's TRIM only removes the regular space (character 32). Spaces copied from web pages are often non-breaking spaces (character 160), which TRIM ignores. Paste the column here, use "Trim leading/trailing only", and paste it back.
How can I remove all whitespace, including line breaks?
Choose "Remove all spaces" and turn on "Remove line breaks too". Everything — spaces, tabs and line breaks — is removed and the result becomes one continuous line.
There's still a gap after removing spaces. Why?
It's probably a special character such as a non-breaking or zero-width space. Check the counts under the input box and make sure the matching option is on. If a gap remains, it may be a wide punctuation mark rather than a space.
Can I count characters without spaces?
Yes — after "Remove all spaces", the "After" figure is your character count without spaces. For bytes and platform limits, use the character counter.

Related tools