Skip to content

Formatters & Code

Remove Spaces

Trim, collapse or strip whitespace from text.

Runs in your browser
Input · source
lines: 0chars: 0size: 0 B
Cleaned · result
lines: 0chars: 0size: 0 B
live

Understanding whitespace cleanup

Four cleanups, one toggle each.

Whitespace is invisible until it isn't — and then it's everywhere.

Trim — leading and trailing only.

Trim mode strips whitespace from the start and end of each line, leaving the middle alone. Useful for cleaning up exports where every line picked up a stray tab. The most conservative option — it never changes the visible shape of paragraphs, only the bytes around them.

Collapse — many spaces become one.

When text has been mangled by copy-paste, you often end up with double or triple spaces between words. Collapse mode reduces every run of spaces and tabs to a single space. Doesn't touch newlines, so paragraph structure survives. Run after Trim for thorough whitespace normalisation.

Strip — every whitespace character.

The nuclear option: every space, tab, newline, and other whitespace character disappears, packing the input into a single contiguous run of non-whitespace. Useful for generating identifiers ("Hello World" → "HelloWorld"), comparing strings byte-for-byte ignoring layout, or minifying snippets where whitespace doesn't matter.

Drop blank lines.

Sometimes you have a list separated by blank lines and you want it dense — drop-blank-lines collapses runs of empty lines but leaves non-empty content alone. Combined with Trim, this gets you from a messy paste into a clean one-thing-per-line list.

Non-breaking spaces and other invisibles.

A regular space is U+0020. A non-breaking space is U+00A0. They look identical and most tools treat them as the same for layout, but byte-for-byte they differ. The Strip and Collapse modes handle both, but Trim only catches the regular space. If your input came from a Word document or a Wikipedia paste, expect U+00A0 and use Strip / Collapse for thorough cleanup.

Frequently asked questions

Quick answers.

What's the difference between trim and strip?

Trim removes leading/trailing spaces only. Strip removes every whitespace character including those between words.

Does it handle tabs?

Yes — tabs, regular spaces, non-breaking spaces and other Unicode whitespace are all handled.

Will it remove blank lines?

Yes — pick the 'remove blank lines' mode to drop any line containing only whitespace.

Is my text uploaded?

No — runs entirely in your browser.

Is the tool free?

Yes — fully free, no signup.

People also search for

Related tools

More in this room.

See all in Formatters & Code