Skip to content

Whitespace Cleaner

Trims trailing spaces, collapses runs of blanks, converts tabs and removes empty lines.

Trims trailing spaces, collapses repeated blank lines, converts tabs, and removes the invisible characters that come along with a copy-paste. Those last ones are the reason two identical-looking strings compare unequal in a spreadsheet.

🔒 Runs entirely in your browserwhitespacecleanformat

Text

Clean

Result

Characters in

44

Characters out

39

Removed

5

How to use it

  1. Paste the text as it is

    A warning appears above the options if there are invisible characters in it, with a count — that alone is often the whole answer to why something is not matching.

  2. Pick what to clean

    Trailing spaces and blank-line collapsing are safe on anything. Collapsing repeated spaces is not: it is applied only after the indentation at the start of a line, so code and nested lists survive.

  3. Check the character count

    The in, out and removed figures tell you how much came off. A large removal on text that looked clean means it was full of invisible characters, and a negative figure means the cleanup split something — an emoji held together by joiners counts as one character before and several after.

Common questions

What counts as an invisible character?

Zero-width spaces, the byte-order mark, soft hyphens and the like — characters that render as nothing and survive a copy-paste, then break search, comparison and spreadsheet keys. Non-breaking spaces are left alone here, because those are usually deliberate typography.

Will collapsing spaces ruin my code?

The indentation is preserved — collapsing only applies after the first non-space character of a line. Alignment inside a line, such as a column of comments, does not survive, so leave the option off for code you care about.

Should I use this or the invisible-character tool?

This one for a quick clean-up of ordinary text. The invisible-character tool when you need to know exactly what is in there — it names each character, says what it is for, and points at where in the text it sits.

Feed it from

Next

These accept what this tool produces, so the result can go straight in.