Remove extra spaces from text

Paste your text and fix its spacing: repeated spaces become one, spaces at the start and end of lines disappear, and odd space characters turn into normal ones.

  • Free
  • No sign-up
  • Runs in your browser
remove-extra-spaces

100% private — your text is processed in your browser and never sent to any server.

How it works

Paste your text

From a web page, a PDF, a document or an email.

Choose the clean-up

Tidy the spacing, remove every space or join all lines into one.

Copy the result

Paste the tidy text wherever you need it.

Spaces you cannot see cause visible problems

Extra spaces are easy to overlook and surprisingly costly. A double space between words looks sloppy in a published text. A space at the end of a name stops a lookup from matching in a spreadsheet. Spaces before a comma break the look of a paragraph, and a "space" that is actually a non-breaking space refuses to be found by a search. This tool normalises all of them in one step.

What "tidy spaces" does

  • Replaces runs of two or more spaces or tabs with a single space.
  • Removes spaces and tabs at the start and end of every line.
  • Turns unusual space characters (non-breaking space, thin space, ideographic space and similar) into a normal space. These often come from web pages and word processors and behave differently from a regular space when you search or compare text.
  • Optionally turns tabs into spaces, and optionally fixes the spacing around punctuation by removing spaces before commas, full stops, colons and question or exclamation marks, and adding a space after a comma or semicolon that is stuck to the next word.

Remove every space

The second action deletes all spaces, tabs and non-breaking spaces while keeping the line breaks. It is what you need for a phone number written as 612 34 56 78, a bank account number copied with groups, a code that should not contain spaces or a string you want to compare without spaces.

Join all lines into one

The third action replaces every line break, together with the spaces around it, with a single space. It is a quick way to turn a text that was wrapped at a fixed width into one continuous paragraph.

What it does not do

The tool works on characters, not on meaning. The punctuation option follows simple rules and is designed for ordinary prose; check the result if your text contains code, decimal numbers, URLs or languages with their own spacing conventions. Spaces inside quoted strings and code are treated like any other spaces. To remove blank lines as well, use the remove empty lines tool.

In Excel and Google Sheets

With the text in A2 (here two spaces before and after, and several between the words):

Spreadsheet formulas for this calculation
To getFormulaResult
Single spaces between words, none at the ends=TRIM(A2)hello world
Also swap non-breaking spaces for normal ones=TRIM(SUBSTITUTE(A2,CHAR(160)," "))hello world
Remove every space=SUBSTITUTE(A2," ","")helloworld
Also remove line breaks and other hidden characters=TRIM(CLEAN(A2))hello world

The formulas use English function names and commas. If your Excel or Google Sheets is set to another language, the function names change, and in many countries the separator between arguments is a semicolon.

  • TRIM only removes the normal space (character 32). Text copied from a web page often has non-breaking spaces (character 160), which TRIM leaves alone: that is what the second formula is for.
  • Paste the formula result as values (Paste Special, Values) before deleting the original column.
  • The tool removes all of these in one go, and shows how many spaces it took out.

Frequently asked questions

How do I remove double spaces from a text?

Paste it and leave "Tidy spaces" selected. Every run of spaces or tabs becomes a single space and the ends of each line are trimmed.

Why does a space not get removed by search and replace?

It is probably a non-breaking or other unusual space character. "Tidy spaces" converts those to normal spaces first, so they can be collapsed.

How do I remove all the spaces from a text?

Choose "Remove every space". Spaces, tabs and non-breaking spaces are deleted; line breaks are kept.

Can I turn line breaks into spaces?

Yes. "Join all lines into one" replaces every line break with a single space.

Does it fix spaces before commas?

Yes, with the option "Fix spaces around , ; . : ! ?". It removes spaces before those marks and adds one after a comma or semicolon that touches the next word.

Is my text uploaded anywhere?

No. It is processed in your browser.

How do I remove extra spaces in Excel?

Use =TRIM(A2): it leaves one space between words and removes those at the start and end. If the text comes from a web page and still looks spaced, use =TRIM(SUBSTITUTE(A2,CHAR(160)," ")).