Whitespace Cleaner guide
Paste messy text from a PDF, email, or spreadsheet and get clean spacing back: no double spaces, no stray tabs, no empty lines, no invisible characters. The tool tells you exactly how many characters it removed.
The four cleanup options
Trim each line removes spaces and tabs from the start and end of every line. It fixes indentation left over from emails and the trailing spaces most editors do not show you.
Collapse spaces turns any run of spaces or tabs inside a line into exactly one space. Three spaces become one. A tab between two words becomes a space. It does not touch line breaks, so your paragraphs stay separate.
Remove blank lines deletes empty lines. With trim on, a line that only held spaces or tabs is empty too, so it goes as well. Use it for lists and data. Leave it off for prose if you want to keep the empty line between paragraphs.
The invisible-character option converts non-breaking spaces (U+00A0) to normal spaces and deletes zero-width characters: the zero-width space (U+200B), zero-width non-joiner (U+200C), zero-width joiner (U+200D), and the byte order mark (U+FEFF). This is the option that fixes problems you cannot see.
Worked example
Say you copy two lines from a PDF invoice. The first line has two leading spaces, a non-breaking space between Invoice and total, three spaces before $1,250, and two trailing spaces. Then comes an empty line. The second line starts with two tabs, has a zero-width space hiding after Due date:, and ends with two spaces. That is 49 characters.
With all four options on, you get two clean lines: Invoice total: $1,250 and Due date: Oct 1. That is 37 characters, so the counter reports 12 removed: 2 leading spaces, 2 extra spaces in the gap, 2 trailing spaces, 1 blank line break, 2 tabs, 1 zero-width space, and 2 more trailing spaces. The non-breaking space is replaced, not removed, so it does not count.
Invisible characters cause real bugs
A non-breaking space prints exactly like a normal space, but software treats it as a different character. A spreadsheet VLOOKUP for John Smith will not match John Smith if one of them has U+00A0 in the middle. A find-and-replace for double spaces will skip it. Excel's TRIM function does not remove it either, which catches a lot of people.
Zero-width characters are worse, because they have no width at all. They arrive in text copied from websites, chat apps, and some CMS editors. The byte order mark sneaks into the start of files saved by older Windows tools. Symptoms: a password that is correct but fails, a CSV header that does not match, a URL that 404s, a JSON key that looks right but is not found, or a word count that is off by one.
If two strings look identical and your code or spreadsheet says they are not, run both through this cleaner and compare again.
Where messy whitespace comes from
PDFs are the biggest offender. They store text as positioned fragments, so copying adds hard line breaks, double spaces where justified text was stretched, and tabs where columns were. Word documents add non-breaking spaces after certain punctuation and in auto-formatted text. Spreadsheet exports pad cells with trailing spaces. Emails add indentation on quoted replies. HTML pages copied into a doc bring characters along as U+00A0.
Mistakes to avoid
Cleaning code or Markdown with every option on. Python uses indentation as syntax, and Markdown uses leading spaces for nested lists and code blocks. Trim and collapse will flatten both. For code, only use the invisible character fix.
Removing blank lines in prose. Paragraphs are separated by an empty line in most plain text formats. Delete those and your whole document becomes one block. Keep that option off unless you are cleaning a list.
Assuming the cleaner fixes broken line wraps. Text from a PDF often has a hard line break in the middle of every sentence. This tool keeps line breaks as they are, apart from removing empty lines. Rejoining wrapped lines is a separate job.
How we calculate: sources
Frequently asked questions
How do I remove extra spaces from text?
Paste the text and keep collapse spaces on. Every run of spaces or tabs becomes a single space. Add trim each line to remove spaces at the start and end of lines.
How do I remove blank lines?
Tick remove blank lines. Empty lines are deleted and the remaining lines close up. With trim each line on, lines holding only spaces or tabs count as empty too.
What is a non-breaking space?
A non-breaking space (U+00A0) looks like a normal space but is a different character. Word processors and web pages insert them, and they break searches, formulas, and matching. The tool converts them to regular spaces.
What are zero-width characters?
Invisible characters with no width: zero-width space (U+200B), zero-width non-joiner and joiner (U+200C, U+200D), and the byte order mark (U+FEFF). They hide in copied text and make identical-looking strings fail to match. The tool deletes them.
Why does text copied from a PDF have weird spacing?
PDFs store text as positioned fragments, not flowing paragraphs. Copying them often adds line breaks mid-sentence, double spaces, and stray tabs. Trim and collapse fix the spacing.
Will it change my words or punctuation?
No. It only touches spaces, tabs, blank lines, non-breaking spaces, and zero-width characters. Letters, numbers, and punctuation are left alone.
Is my text uploaded?
Everything runs in your browser. Nothing you enter is uploaded to a server or stored by us.
Does Excel TRIM remove non-breaking spaces?
No. Excel's TRIM removes regular spaces only. Non-breaking spaces (character 160) survive, which is why cleaned cells can still fail lookups. This tool converts them.
Can I remove all spaces entirely?
No. The tool normalizes spacing rather than deleting it, so words stay separated. Collapse spaces is as aggressive as it gets.