Remove Extra Spaces

Paste text with double spaces, tabs between words or spaces at the line ends. You get one plain space between words and nothing at either end of a line.

How it works

Every run of spaces and tabs inside a line becomes a single space, and the spaces at the start and end of each line are removed. Empty lines at the very start and end of the text go too.

No-break spaces and the other unusual space characters, such as the thin space, the narrow no-break space and the wide space used in Chinese and Japanese text, become plain spaces first. They look like spaces but do not match a space in a search, so they cause quiet bugs.

Squeeze runs of blank lines to one leaves at most one empty line between paragraphs. The note under the result counts the lines that changed. Everything runs on this page.

How to use it

  1. 1 Paste your text into the Text box.
  2. 2 Turn on Squeeze runs of blank lines to one if the text has big gaps between paragraphs.
  3. 3 Read the count below the result to see how many lines were changed.
  4. 4 Copy the result, or download it as a .txt file.

Good to know

  • Two spaces after a full stop is an old typewriter habit. This tool turns them into one, which is the usual style today.
  • A search that cannot find a phrase you can see often fails because of a no-break space. Run the text through here first.
  • Indentation is removed too, because it is spaces at the start of a line. For code, use Trim Whitespace with End only instead.
  • Text Cleaner does this and more in one pass, such as removing HTML tags and curly quotes.

Browser support

  • Chrome 94 and later
  • Firefox 93 and later
  • Safari 16.4 and later
  • Edge 94 and later

These are the oldest versions with everything the tool uses. They are worked out from the tool itself, so they change when it does.

Version numbers checked on 2026-09-04.

Why a phrase you can see on the screen does not turn up in a search

You paste a product description from a supplier's website into your shop. Later, a search for "stainless steel" does not find it, though the words are right there. The usual cause is a character that looks like a space but is not one. Web pages use the no-break space to stop a line wrapping between two words, and it survives a copy and paste. To a search, "stainless" plus a no-break space plus "steel" is not the same text as the phrase you typed.

Paste the description here and every no-break space becomes a plain one. So do the other unusual spaces: the thin space some designers put around a dash, the narrow no-break space French uses before a colon or a question mark, and the wide space from Chinese and Japanese text. After that, the search matches, because the text now holds the characters it seems to hold.

The same pass handles the visible mess. "Free delivery on all orders" becomes "Free delivery on all orders", with one space between words. Tabs between words become a space too, which helps when text comes out of a table. Spaces at the start and end of every line go, and the note under the result tells you how many lines changed, for example "Changed 12 of 40 lines", so you can see the tool did not rewrite text that was already clean.

Blank lines are left alone unless you ask. Turn on Squeeze runs of blank lines to one and any gap of several empty lines becomes a single empty line, which is what you want for prose copied from a PDF or an email. Empty lines at the very start and end of the text are always removed.

There are limits. Because indentation is spaces at the start of a line, this tool removes it, so it is the wrong choice for code or for a nested list; Trim Whitespace with End only is the right one there. It also writes the result with plain line breaks, so a file with Windows line breaks comes out with Unix ones, which nearly every program reads fine. It does not remove zero-width characters, which are not spaces; the Whitespace Visualizer finds those. It takes up to 1 MB of text at a time.

Frequently asked questions

Does this remove the line breaks too?

No. Every line stays a line. Only empty lines at the start and end go, and runs of blank lines if you turn on the switch for that.

What is a no-break space and why replace it?

It is a space that stops a line from wrapping between two words, often found in text from web pages and Word. It looks like a normal space but is a different character, so searches and spreadsheets treat it differently. Replacing it makes the text behave as it looks.

Will it remove the indentation from my code?

Yes, because indentation is spaces at the start of a line. To clean up code, use Trim Whitespace with End only, which keeps the indentation.

Is my text uploaded?

No. The cleanup runs in your browser, on this page.

Related tools

Your files are processed on your device and are not uploaded. You can verify this in your browser’s developer tools under the Network tab.