Whitespace and Invisible Character Cleaner

Paste text that refuses to match, sort or validate, and see exactly which invisible characters are in it before removing them.

—

What this tool does

Text pasted from a browser, a PDF, a spreadsheet export or a chat application routinely carries characters that cannot be seen: a zero-width space between two words, a non-breaking space where an ordinary one was expected, or a byte order mark at the start of a value. To a human the text looks correct. To a database it is a different string, so a unique key collides, a lookup returns nothing, or a sort order looks random.

This page first reports how many of these characters are present, then removes the ones you select, so you can confirm the diagnosis rather than guessing.

Method

The cleaner targets specific Unicode ranges rather than stripping anything unusual, so legitimate scripts are never damaged:

OptionCharacters removedCode points
zero-widthZero-width space, joiners, directional marks, byte order markU+200B–U+200F, U+202A–U+202E, U+2060–U+2064, U+FEFF
non-breaking spacesNon-breaking space, narrow no-break space, figure spaceU+00A0, U+202F, U+2007
collapse repeatsRuns of spaces or tabs become one space; three or more newlines become two—
trim linesLeading and trailing whitespace on every line, and at the start and end of the text—

Letters carrying diacritics, Thai and Devanagari marks, emoji and ordinary punctuation are all left untouched, because none of them fall in the ranges above.

Example

BeforeProblemAfter
hello\u200Bworldzero-width space inside a wordhelloworld
1 000\u00A0VNDnon-breaking space1 000 VND
key leading and trailing spaces break a lookupkey

Not all whitespace is the space bar

A string that looks like it has ordinary spaces may contain any of a dozen whitespace characters, and they do not compare equal. The common ones:

CharacterCode pointLooks likeComes from
No-break spaceU+00A0A spaceHTML  , Word, French typography
Narrow no-break spaceU+202FA thin spaceFormatted documents
Ideographic spaceU+3000A wide spaceCJK input methods
Zero-width spaceU+200BNothingLine-breaking hints copied from a page
BOMU+FEFFNothingStart of a UTF-8 file from some exporters
TabU+0009A wide gapSpreadsheet copies, indentation

Only the last two are visible as anything other than a space, which is why the others cause matching bugs that look inexplicable: the value prints identically to the expected one and compares unequal.

Why it breaks lookups

A database lookup for an email address fails if the stored value has a trailing no-break space and the input does not — or the reverse. A CSV import that ignores a column often has a BOM in its first header. A username that "does not exist" can contain a zero-width space pasted from a chat application. In each case the fix is normalisation at the boundary, not a change to the lookup.

Cleaning without damaging the text

This tool reports what it found before removing it, which matters because a blanket strip is not always safe. Removing a zero-width joiner from an emoji sequence changes how it renders. Removing bidi marks from Arabic or Hebrew text breaks its display order. The cleaner targets whitespace and the invisible format characters that break identifiers, and leaves the joiners and direction marks alone.

For an identifier field — email, username, key — it is reasonable to strip aggressively. For prose, normalising to NFC and collapsing ordinary whitespace is the safe pass, and anything more is a decision that should be made deliberately.

Line endings

Windows uses \r\n, Unix uses \n, and some files use \r alone. A tool that only handles \n leaves a carriage return at the end of every line, which is invisible in most editors and breaks comparison and sorting. This tool normalises line endings as part of cleaning, so the result is consistent regardless of where the text came from.

Frequently asked questions

Does it remove line breaks?

No. It removes invisible characters, collapses runs of spaces and trims each line, but it keeps the line structure. If the problem is hard-wrapped prose from a PDF, use Remove Line Breaks; if it is extra blank lines, the cleaner can collapse those without joining the text.

What are zero-width characters?

Characters that occupy no visible space but still count as data: the zero-width space, the zero-width joiner and non-joiner, and the byte order mark. They usually arrive when text is copied from a web page, a PDF or a chat app.

What is a non-breaking space?

A space that looks like a normal space but is a different character (U+00A0). It stops a line from breaking between two words, and it is the most common reason “identical” text fails to match.

Why does cleaning text matter?

Search, comparison, unique database keys, sort order and code all treat these characters as significant. Removing them makes text behave the way a human reader expects.

Will this remove needed spaces?

No. Ordinary spaces are preserved unless you ask for runs of them to be collapsed. Only invisible, non-standard characters are removed.

How many invisible characters are in my text?

The counter above the result shows how many zero-width, non-breaking and other unusual space characters were found before cleaning.

Sources

  • Unicode Standard, general category Cf (format) and the special space characters in Zs.
  • Unicode Standard, U+FEFF byte order mark and its use as a zero-width no-break space.

Everything runs in your browser — nothing you type is uploaded.