Text tools

Remove Extra Spaces

Remove Extra Spaces

Collapse double spaces and tabs into single spaces and trim spaces at the start and end of every line.

About this tool

About Remove Extra Spaces

Double spaces after full stops, columns of spaces copied from a PDF, tabs mixed with spaces and stray spaces at the ends of lines make text look sloppy and break comparisons, imports and formulas. Paste your text and every run of spaces or tabs inside a line becomes a single space, spaces at the start and end of each line are trimmed, and runs of blank lines are reduced to one. Non-breaking spaces and other unusual Unicode spaces that look normal but aren't are converted into ordinary spaces, and invisible zero-width characters are removed, both common reasons why two cells or lines that look identical don't match. Words are never joined: only the extra spacing goes. If you need to keep indentation at the start of lines, as in code or a nested list, change Trim to Trailing spaces and only the spaces inside lines are collapsed. The summary shows how many runs and lines were changed. Your text stays in your browser.

Built and maintained by Abhi JainUpdated

How to Remove Extra Spaces

  1. 1

    Paste your text

    Paste into the Text box or open a file.

  2. 2

    Check the options

    Collapse extra spaces and Trim: Both ends are on. Choose Trailing spaces instead to keep indentation.

  3. 3

    Copy the result

    Copy or Download the cleaned text.

Remove Extra Spaces: questions and answers

Will it remove the spaces between words?

No. Runs of two or more spaces (or tabs) become exactly one space, so words stay separated.

What is a non-breaking space?

A space character (U+00A0) that stops a line from wrapping between two words. It looks like a normal space but isn't equal to one, which breaks searches, VLOOKUPs and CSV imports. Normalise odd spaces converts it.

How do I see where the extra spaces are?

Paste the text into the Whitespace Visualizer, which shows every space, tab and invisible character.

Does it work on code?

Collapsing spaces inside code can change string values and alignment, so for code set Trim to Trailing spaces and untick Collapse extra spaces, or use a code formatter instead.