Remove Extra Spaces

Trim spaces from line ends and collapse repeated spaces.

Result

too many spaces
indented with a tab
trailing
3 lines · 44 bytes

What does removing extra spaces do?

Text copied from a PDF, an email, a spreadsheet or a web page often carries spaces you cannot see: spaces at the start or end of lines, double spaces between words, and tab characters. They cause trouble when you compare, search or import the text.

This tool cleans each line on its own. It can trim the start, the end or both, and it can collapse any run of spaces or tabs inside a line into a single space. The sample line " too many spaces " becomes "too many spaces". Line breaks are kept.

How to use the Remove Extra Spaces

  1. Paste your text.
  2. Choose where to trim: both ends, start, end or nothing.
  3. Choose whether to collapse repeated spaces.
  4. Copy the cleaned text.

Real situations

When people use the Remove Extra Spaces

  • 1

    Clean text copied from a PDF

    Remove the odd gaps and indents that come with copied PDF text.

  • 2

    Fix data before importing

    Trailing spaces make "Paris" and "Paris " different values. Trim them first.

  • 3

    Tidy code or notes

    Strip trailing whitespace from code or notes so it does not create noisy changes in a diff later.

  • 4

    Normalize spacing in a list

    Make the spacing of a list consistent before you sort it or remove its duplicate lines.

FAQ

Remove Extra Spaces: questions answered

What does the sample become?

With both-end trimming and collapse on, the three sample lines become "too many spaces", "indented with a tab" and "trailing". The tab at the start of the second line is trimmed.

Does it remove line breaks?

No. Each line stays on its own line. To remove blank lines use the remove empty lines tool, and to merge lines into one use the join lines tool.

What is the difference between trim and collapse?

Trim removes spaces at the beginning or end of a line. Collapse reduces repeated spaces or tabs in the middle of a line to one space. You can use either or both.

Will it remove all spaces?

No. It leaves single spaces between words. It cannot delete every space, because that would run words together.

Does it treat tabs as spaces?

Yes when collapsing: two or more spaces or tabs in a row become one space. Trimming also removes tabs at the ends of lines.

Why do my lists still show duplicates after trimming?

There may be other invisible differences, such as non-breaking spaces or different letter case. Trimming handles ordinary spaces and tabs at the ends of lines.

Is this Remove Extra Spaces free and private?

Yes. It is free with no sign-in, and every calculation runs inside your browser. Nothing you type is sent to a server or stored, and the page keeps working offline once it has loaded.

Private by design. No accounts, no cookies, no tracking. Everything you type stays on your device.

How we keep it that way