Skip to content
MoneyDeck

Remove Extra Spaces

Collapse double spaces and tabs, trim lines and tidy blank lines

Updated · Free, no signup

Cleaned text

This sentence has too many spaces.

The second line is messy too.

Characters removed

24

Characters before

89

Characters after

65

Lines after

3

  • Removed 24 whitespace characters (27% of the original length).

About the Remove Extra Spaces

Remove Extra Spaces cleans up text that has picked up messy whitespace. It collapses runs of spaces and tabs into a single space, trims the spaces at the start and end of every line, and can collapse or delete empty lines, so text copied from PDFs, emails, spreadsheets or web pages becomes tidy in one click.

It is useful for writers fixing double spaces after full stops, developers cleaning data before importing it, students pasting quotes from PDFs, and anyone preparing text for a form or a CMS that shows every stray space. The counter shows how many characters were removed so you can see the effect at a glance.

Line breaks are kept unless you choose to remove blank lines, so paragraphs and lists stay intact. Optionally, invisible look-alike spaces such as the non-breaking space (U+00A0) and the ideographic space are treated as ordinary spaces too. Everything runs in your browser; your text is not uploaded.

How to use the remove extra spaces

  1. 1Paste the text you want to clean into the box.
  2. 2Keep "Collapse runs of spaces" on to turn double spaces and tabs into single spaces.
  3. 3Keep "Trim" on to strip spaces from the start and end of each line.
  4. 4Choose whether blank lines are kept, collapsed or removed.
  5. 5Copy the cleaned text.

Formula and method

line → replace /[ \t]+/ with " " → trim; blank-line runs → one (or none)

The text is split into lines. On each line, every run of one or more spaces or tab characters is replaced with a single space, then any spaces or tabs at the start and end of the line are removed. Line breaks themselves are not touched by these two steps, so paragraphs and list items stay on their own lines.

Blank lines (lines that are empty or contain only whitespace) are then kept, collapsed so that no more than one blank line appears in a row (with blank lines at the very start and end removed), or deleted entirely. When the Unicode option is on, look-alike spaces such as the non-breaking space U+00A0, the en/em/thin spaces U+2000–U+200A, the narrow no-break space U+202F and the ideographic space U+3000 are first converted to ordinary spaces. "Characters removed" is the length before minus the length after, counted in Unicode code points.

Worked examples

Clean messy pasted text

Multiple spaces and the two tabs become single spaces, the spaces around each line are trimmed, and the two blank lines in the middle collapse into one. The 89-character original shrinks to 65 characters, so 24 whitespace characters were removed.

Fix double spaces after full stops

Each of the three double spaces after a full stop becomes a single space, removing 3 characters and leaving "One. Two. Three. Four.".

Turn a spaced-out list into a compact one

Leading and trailing spaces are trimmed from each item and every blank line is removed, leaving three lines and 18 characters including the two line breaks.

Frequently asked questions

How do I remove double spaces in text?+

Paste your text and keep "Collapse runs of spaces and tabs" switched on. Every sequence of two or more spaces becomes a single space, which fixes double spaces after full stops and gaps left by copy-pasting.

Will this remove my line breaks?+

No. Line breaks are kept so paragraphs and lists stay separate. Only blank lines are affected, and only if you choose to collapse or remove them. To join lines into one paragraph, use a remove line breaks tool instead.

Why do some spaces not disappear in Word or Google Docs?+

They are often non-breaking spaces (U+00A0) or other Unicode spaces that look identical to a normal space. Turn on the Unicode spaces option and they are converted to ordinary spaces before being collapsed.

Does it remove tabs?+

Yes. When collapsing is on, tabs are treated like spaces: a tab or a mix of tabs and spaces becomes a single space, and tabs at the start or end of a line are trimmed. Turn collapsing off to keep tab indentation.

What counts as a blank line?+

A line that is empty or contains only spaces and tabs. With "Collapse" it keeps at most one blank line between paragraphs; with "Remove" every blank line is deleted so all remaining lines sit together.

Related tools