ToolLineup

Remove Extra Spaces

This tool normalises whitespace: every run of spaces and tabs inside a line collapses to a single space, and what remains at the ends is trimmed. Line breaks are left alone, so the shape of the document survives. There is also an option that removes invisible characters — zero-width spaces, byte order marks, soft hyphens and directional marks. These are invisible by definition, which makes them one of the most frustrating things to debug: two strings that look identical on screen refuse to compare equal, a search finds nothing, a lookup key misses, or a hash differs. Text copied from PDFs, web pages and word processors is full of them.

How it works

Collapses every run of spaces and tabs inside a line down to a single space, and trims what is left at the ends. Line breaks are left alone, so the shape of the document survives.

The invisible-character option removes zero-width spaces, byte order marks, soft hyphens and directional marks. These are invisible by definition and are a common reason two strings that look identical refuse to match, compare equal or hash the same.

Everything runs in your browser — nothing you paste is sent to a server.

Text input
Paste or type your text here…
Result

0 characters removed.

Invisible characters, and why they ruin your day

A zero-width space is a real character that occupies no visual width. Paste text containing one into a form, compare it against the "same" string, and the comparison fails — with nothing on screen to explain why.

The characters removed by this option are:

  • Zero-width space, joiner and non-joiner — inserted by word processors and by copy-paste from web pages.
  • Byte order mark — added to the front of UTF-8 files by some Windows tools.
  • Soft hyphen — an invisible "you may break here" hint, common in text lifted from PDFs.
  • Directional marks — used for right-to-left text, and left behind when that text is edited.

If a string comparison, a lookup or a hash is failing for no visible reason, run both sides through this first.

Structure is preserved

Only horizontal whitespace is touched. Line breaks stay exactly where they are, so a list stays a list and a paragraph stays a paragraph.

Frequently asked questions

How do I remove extra spaces?

Paste your text into the left panel. Repeated spaces and tabs collapse to a single space immediately.

Are line breaks affected?

No. Only horizontal whitespace inside each line is collapsed, so the document keeps its structure. Blank-line handling is a separate option.

What are invisible characters?

Zero-width spaces, byte order marks, soft hyphens and directional marks. They take up no visible width but are real characters in the string.

Why do invisible characters matter?

They are the usual reason two strings that look identical will not match, a search returns nothing, or a hash differs. Text copied from PDFs, web pages and word processors frequently contains them.

Does it convert tabs to spaces?

A run of tabs and spaces collapses to a single space, so a lone tab between words becomes a space. Indentation is not preserved — this tool normalises, it does not reformat code.

Is my text sent anywhere?

No. Everything runs in your browser.

Related tools