Whitespace Cleaner
Trim, collapse, and normalize whitespace in text — in-browser
Input
Cleaned Output
Hello World Tab here Multiple spaces here Blank lines above And here too
About the Whitespace Cleaner
This tool cleans whitespace in text: trimming each line, collapsing runs of spaces into one, removing blank lines and normalising line endings between Windows CRLF and Unix LF. Each option is separate so you apply only what you need.
Clean whitespace to fix text that came from somewhere else. Copying out of a PDF leaves double spaces and trailing tabs, pasting from a website brings non-breaking spaces, and moving files between Windows and macOS mixes line endings.
Invisible characters cause visible problems. Trailing spaces break exact-match comparisons and make diffs noisy; non-breaking spaces look identical to normal ones but fail a search; mixed line endings make a file appear entirely rewritten in version control when nothing actually changed.
Each operation is a separate toggle, because collapsing all spaces would destroy indentation in code while trimming line ends is nearly always safe. Everything runs in your browser.
How to use the Whitespace Cleaner
- Paste your text. Enter the text with whitespace problems.
- Choose the operations. Trim line ends, collapse spaces, drop blank lines or normalise line endings.
- Review the output. Check that indentation you wanted to keep survived.
- Copy the clean text. Take the cleaned result.
Whitespace Cleaner features
- Trim leading and trailing whitespace from every line
- Collapse runs of spaces into one
- Strip all whitespace entirely
- Normalise line endings between Windows and Unix
- Remove blank lines
- Each option applied independently
- Copy the result
Frequently asked questions
Why does invisible whitespace cause so much trouble?
Because it breaks comparisons that look identical on screen. A trailing space stops two strings matching, defeats a lookup, and makes a diff show a line as changed when nothing visible did.
What is the line-ending option for?
Windows ends lines with a carriage return and a newline; Unix and macOS use a newline alone. Mixing them produces stray characters in diffs, doubled blank lines, and shell scripts that fail with confusing errors.
What is the difference between collapsing and stripping?
Collapsing reduces runs of spaces to a single space, keeping words apart. Stripping removes whitespace altogether, which is right for cleaning a pasted code or hash value and wrong for prose.
Will it keep my paragraph breaks?
Yes, unless you ask it not to. Trimming and collapsing leave line structure alone; only the remove-blank-lines option affects paragraph separation.