The four cleaning passes, in the order they run
Each checkbox is a separate pass, and they run in a fixed order. That order matters, because later steps see the result of earlier ones. Line endings are first normalised to \n.
- Strip invisible chars: deletes the zero-width space (U+200B), zero-width non-joiner (U+200C), word joiner (U+2060), soft hyphen (U+00AD), byte-order mark (U+FEFF) and any zero-width joiner (U+200D) that is not part of an emoji sequence. The non-breaking space (U+00A0) is turned into an ordinary space instead, because it stands for a real gap between words.
- Collapse spaces: any run of two or more spaces or tabs becomes one space. A single tab on its own is left alone.
- Trim lines: spaces and tabs at the start and end of every line are removed.
- Remove blank lines: any run of two or more line breaks becomes one. Because trimming has already emptied whitespace-only lines, those are removed as well.
The result is trimmed at both ends before being displayed.
Worked example
Suppose the input is: two leading spaces, Hello, two non-breaking spaces, world, a space, a zero-width space and a space; then two empty lines; then a line with three leading spaces, second, two tabs and line; then trailing blank lines. With all four options on, the output is exactly two lines:
Hello world
second line
Mistakes and limits to know about
- Paragraph spacing disappears. With "Remove blank lines" on, a blank line between paragraphs is removed too. If you want to keep paragraph gaps, untick that option.
- Zero-width characters are deleted, not replaced. A zero-width space inside a word turns
unbreakableintounbreakable, so the word is not split. A zero-width joiner between emoji (a family, a couple, a person with a profession) is kept, so those emoji stay whole. The zero-width non-joiner is always removed, though Persian and Indic scripts use it on purpose, so untick the option for text in those languages. - Not every odd character is covered. Thin spaces, hair spaces and the left-to-right and right-to-left marks (U+200E, U+200F) are left untouched. The Find and Replace tool in regex mode can remove them: a pattern such as
[\u2009\u200E\u200F]works. - Typography is not changed. Curly quotes, dashes and ellipsis characters stay as they are; the cleaner only deals with whitespace.
Invisible characters are the usual reason a copied value fails to match in a spreadsheet or a search box, and why two names that look identical are treated as different. Running the text through the cleaner and then through Remove Duplicate Lines is a reliable way to deduplicate pasted data. To check the effect on length, paste before and after into the character counter.