Whitespace Cleaner
Remove extra spaces, tabs, and blank lines from text, with options to normalize tabs to spaces at a custom width. Useful for cleaning up text pasted from a PDF or fixing formatting leftovers in code and config files, free online in your browser.
Usage examples
Cleaning up formatting leftovers from pasted text
Tidy up stray extra spaces and blank lines mixed into text copied from a word processor or webpage.
Normalizing tabs to spaces in code or config files
Unify text that mixes tabs and spaces into a consistent space width so there's no more display inconsistency.
Trimming excessive blank lines between paragraphs
Clean up a document with too many blank lines from repeated line breaks down to a single blank line between sections.
Fixing text pasted from a PDF
PDFs often paste with a trail of spaces at the end of every line and tabs used for indentation. Turn on trim whitespace per line plus convert tabs to spaces to get back plain, consistently spaced text.
Preparing a CSV-like list for re-pasting
A list copied from a spreadsheet can carry double spaces between columns that didn't line up as a tab. Enable collapse repeated spaces so 'Name Age' becomes 'Name Age', ready to paste somewhere that expects single-space separation.
Frequently asked questions
Is my text sent to a server?
No. All processing happens entirely in your browser, and what you enter is never sent to a server.
What's the difference between the three blank line options?
'Keep all' leaves blank lines untouched. 'Collapse to single' reduces consecutive blank lines to just one. 'Remove all' deletes every blank line.
How do I set the width when converting tabs to spaces?
Turning on convert tabs to spaces reveals a tab width field you can set directly; it defaults to 4.
Can I apply multiple options at once?
Yes. Every option works independently, so you can turn on any combination you need at the same time.
What's the difference between trim whitespace per line and collapse repeated spaces?
Trim whitespace per line only removes spaces at the very start and end of each line. Collapse repeated spaces looks inside the line and reduces any run of multiple spaces in a row down to one. You can use either one alone or both together.
Will this remove spaces that are part of indentation I want to keep, like in code?
If you enable trim whitespace per line, leading spaces used for code indentation will be removed along with trailing ones — this tool doesn't distinguish intentional indentation from stray whitespace, so avoid that option if you need to preserve indented code.
What happens if I paste completely empty or whitespace-only text?
With nothing but spaces or blank lines as input, every option simply has nothing meaningful to act on, so the output is empty or reduced to whatever blank-line setting you chose — no errors are shown.