About Whitespace Cleaner
Strip extra whitespace from any text. Trim each line, collapse consecutive spaces or blank lines, normalize tabs/spaces, remove zero-width characters. Useful when text comes back from a system that mangled the spacing — copy from PDF, paste from Word, output from a code generator.
Why whitespace bugs are sneaky
Whitespace is invisible but semantically loaded. Trailing spaces in a config break some parsers. Mixed tabs/spaces break Python. Zero-width characters confuse search. Two consecutive spaces look like one but compare unequal.
This tool surfaces those issues and cleans them in one pass.
Cleaning options
- Trim trailing whitespace per line (the most common cleanup)
- Trim leading whitespace per line (off by default — preserves indent)
- Collapse multiple spaces to one
- Collapse multiple blank lines to one (or remove all blanks)
- Tabs → N spaces with configurable width
- Spaces → tabs for languages that prefer tabs
- Strip zero-width chars (ZWSP, ZWNJ, ZWJ, BOM)
- Strip non-breaking spaces (U+00A0) → regular space
Common workflows
Clean a PDF copy-paste. PDF text comes with weird character widths and zero-widths. Run through, get clean ASCII.
Normalize a config file. A teammate’s editor saved tabs; your linter wants spaces. Convert.
Fix a hidden ZWSP. A search returns no matches even though the string is visibly there. Strip zero-widths to normalize.
Prepare for diff. Two configs that look identical but diff dirty. Strip whitespace from both, diff again, see real changes.
Frequently asked questions
What gets cleaned?
Tabs vs spaces?
Zero-width characters?
Will my code blocks lose indentation?
BOM removal?
Newline conversion?
Related tools
Last updated: 2025-01-15