Clean Whitespace
Trim lines, collapse repeated spaces, remove empty lines and strip invisible characters to tidy messy text.
Paste or drop
Paste text below, or drop a file instead.
Choose an output
Trim lines, collapse repeated spaces, remove empty lines and strip invisible characters to tidy messy text.
Fine-tune
Optional — sensible defaults are already set.
About Clean Whitespace
Tidy text that has picked up messy spacing from copying out of PDFs, web pages, Word or spreadsheets. It can trim each line, collapse runs of spaces, limit blank lines, convert tabs, and remove invisible characters such as zero-width spaces, which cause confusing bugs because you cannot see them.
When it helps
- Fixing double spaces and stray indentation in text copied from a PDF or website.
- Removing zero-width spaces and byte-order marks that break code, CSV imports or string comparisons.
- Replacing non-breaking spaces that stop text from wrapping or matching in searches.
- Squeezing out the extra blank lines left after deleting content.
Tips
- 'Remove zero-width & non-breaking spaces' deletes zero-width characters, word joiners, byte-order marks and soft hyphens, and turns non-breaking and other special spaces into normal spaces.
- 'Max one blank line in a row' keeps paragraph breaks while removing gaps. 'Remove all empty lines' deletes every blank line, which merges paragraphs visually.
- 'Convert tabs to spaces' uses two spaces per tab. Leave it off for tab-separated data, or the columns will break.
- Trailing spaces at the end of lines are always removed, even with 'Trim each line' off.
Good to know
Quick answers about clean whitespace in your browser.
Run the text through this tool with invisible-character removal on and compare the summary, which reports how many characters were removed. If the number is higher than the visible spaces you expected, the text contained hidden characters.
Only if you turn off 'Trim each line' and 'Collapse multiple spaces'. With the defaults, leading spaces are removed, which flattens indentation in code, YAML and Python.
Yes. There is no sign-up, no watermark and no limit on how many files you process.
No. Files are read and processed locally in your browser, so they never leave your device.
Related tools
Part of the Text Tools collection.