Whitespace cleaner
What is a Whitespace Cleaner?
Text copied from PDFs, web pages, spreadsheets and chat apps often arrives with messy whitespace: double spaces, trailing spaces, stray tabs, empty lines and invisible characters. These cause failed comparisons, broken CSV imports, ugly diffs and validation errors. The whitespace cleaner fixes them in one pass.
How to use it
- Paste your text.
- Choose the clean-up options you need.
- Copy the cleaned text.
Clean-up options
- Trim lines: remove leading and trailing spaces from each line.
- Collapse spaces: replace runs of spaces with a single space.
- Remove blank lines: delete empty lines, or reduce multiple blank lines to one.
- Tabs to spaces: replace tab characters with a set number of spaces.
Example
Input (with trailing spaces and double spacing):
Name: Asha Rao
City: Pune After trimming, collapsing spaces and removing extra blank lines:
Name: Asha Rao
City: PuneInvisible troublemakers
- Non-breaking space (U+00A0): looks like a space but is not matched by many tools; common in text copied from web pages and Word.
- Zero-width space (U+200B): completely invisible; breaks string comparisons and URLs.
- Carriage returns (\r): from Windows line endings, can appear as ^M in Unix tools.
If text still behaves strangely after cleaning, inspect it with the text-to-Unicode tool to see every code point. Do not collapse whitespace in code where indentation matters, such as Python or YAML.
Frequently Asked Questions
Why does my cleaned text still have strange spaces?
It may contain non-breaking or zero-width spaces. Inspect the text with a Unicode viewer to find them.
Will it change my code indentation?
Collapsing spaces would break indentation in Python or YAML, so only use trimming and tab conversion options on code.
How do I remove all blank lines?
Enable the remove blank lines option. Lines containing only spaces are treated as blank after trimming.
Does it change line endings?
Use the line ending converter to switch between Windows and Unix line endings.