Remove Extra Spaces

Paste text and every run of two or more spaces becomes a single space, tabs become spaces, and spaces at the start and end of each line are trimmed. Line breaks are kept, so lists and paragraphs keep their shape.

Characters
0
Words
0
Lines
0

Your text never leaves your device.

How to use

  1. Paste the text with messy spacing into the box.
  2. The cleaned text appears below as you type: single spaces, no indentation, no trailing spaces.
  3. Copy the result or download it as a .txt file.

Examples

  • Before
    Hello world. This has extra spaces.
    After
    Hello world. This has extra spaces.
  • Before
    Name: Anna Smith City: Berlin
    After
    Name: Anna Smith City: Berlin

What gets cleaned

The tool goes line by line and makes three changes:

  1. Leading spaces at the start of a line (indentation) are removed.
  2. Trailing spaces at the end of a line are removed. They are invisible, but they break comparisons, so “apple” and “apple “ look like different values in a spreadsheet or a list of duplicates.
  3. Runs inside the line of two or more spaces or tabs become one space, and a single tab becomes a space.

Nothing else changes: letters, punctuation and line breaks stay exactly as they were.

Where extra spaces come from

Text copied from PDFs and web pages carries the spacing of its layout: justified text, table columns and indentation all turn into runs of spaces. Old documents use two spaces after each period. Spreadsheet exports pad values to a fixed width. Text typed on phones picks up a double space when autocorrect inserts a word. The result looks fine on screen but breaks search, sorting, deduplication and word counts.

Common mistakes

  • Cleaning code or aligned tables. Indentation is meaningful in Python and YAML, and aligned columns in plain-text tables rely on runs of spaces. Clean only prose and data values.
  • Expecting space before punctuation to be fixed. “Hello , world” keeps its space before the comma, because some languages (French: “Bonjour !”) use one deliberately. Use find and replace to remove it.
  • Missing non-breaking spaces with other tools. Excel’s TRIM and many editors ignore the non-breaking space (U+00A0), so values from web pages still do not match. This tool treats it like any other space.
  • Leaving empty lines behind. Lines with only spaces become empty lines. Run remove empty lines afterwards if you want them gone.

Frequently asked questions

How do I remove double spaces from text?

Paste the text into the box above. Every sequence of two or more spaces is replaced by one space immediately, and the cleaned text is ready to copy. It also catches tabs and the invisible non-breaking spaces that text copied from websites often contains.

Does it remove line breaks too?

No. Each line is cleaned separately and the line breaks stay, so a list stays a list. Lines that contained only spaces become empty lines. To join lines, use remove line breaks; to delete the empty lines, use remove empty lines.

What counts as a space?

Any Unicode whitespace: ordinary spaces, tabs, non-breaking spaces (common in text from Word and web pages) and the thin, wide and ideographic spaces used in typography and in Japanese and Chinese. A run of two or more of them becomes one ordinary space. A single non-breaking space is kept, because it is usually there on purpose, as in "10 km".

Should there be one or two spaces after a period?

One. Two spaces after a sentence was a typewriter convention; current style guides, including APA, Chicago and AP, ask for one. This tool removes the second space automatically.

How do I remove extra spaces in Excel or Word?

In Excel and Google Sheets, =TRIM(A1) removes leading and trailing spaces and collapses inner runs, but it does not remove non-breaking spaces from web data. In Word, use Find and Replace: search for two spaces, replace with one, and repeat until nothing is found. Pasting here does it in one step.