Whitespace Remover

Trim, collapse or remove all whitespace from your text

Text with extra whitespace

Cleaned text

Nothing you type here is ever sent anywhere — the cleanup runs entirely in your browser.

About this tool

Extra whitespace sneaks into text from copy-pasting, misaligned tables, or careless formatting — double spaces after periods, trailing spaces at the end of lines, or entire blocks that need to be squeezed tight for a code or data field. This tool offers three modes: collapse runs of spaces and tabs down to a single space while also trimming each line, trim only the leading and trailing whitespace on each line while leaving internal spacing alone, or remove every whitespace character entirely for a completely compact string.

What's the difference between "Collapse" and "Trim lines"?

Collapse mode squeezes multiple spaces or tabs within a line down to one space, and also trims each line's leading/trailing whitespace. Trim lines mode only removes the leading and trailing whitespace on each line, leaving multiple internal spaces untouched.

Does "Remove all whitespace" delete line breaks too?

Yes — that mode removes every whitespace character, including spaces, tabs, and line breaks, producing one continuous string with no gaps at all.

Will this fix indentation in code snippets?

Collapse and Trim lines modes will strip leading whitespace used for indentation, which is useful for plain text but would flatten intentional code indentation — for code, this tool is best used on prose rather than formatted source.

Cleaning up stray spaces

There are three modes. Collapse squeezes runs of spaces and tabs into one and trims each line. Trim lines only clears the space at the start and end of each line and leaves the gaps inside alone. Remove all strips every whitespace character, line breaks included.

Pick the gentle one when you're fixing text. Double spaces after periods, trailing spaces from copy-paste, and tabs from a spreadsheet all vanish under Collapse. Pick Remove all when you need a compact string for a code, an ID or a field that must contain no spaces.

The tool shows the result immediately, so you can try each mode on the same text and see what each one does before copying.

A quick example

Before (Collapse)
  too   many    spaces  here  
After
too many spaces here

Good to know

Remove all joins words together, which makes the text hard to read again. Keep your original around until you've checked the output.