How to Find and Remove Invisible Characters in Text

How to Find and Remove Invisible Characters in Text

Invisible characters are real characters that take up no visible space, so text that looks fine on screen can quietly break your code, your search, or your formatting. The fix is to find the hidden characters and strip them out. Here is how to do both.

The common culprits

These are the invisible characters you will run into most:

  • Zero-width space (U+200B): takes no width at all. Breaks string comparisons and search because two “identical” strings are not equal.
  • Zero-width joiner / non-joiner (U+200D / U+200C): control how nearby glyphs connect. Stray ones corrupt emoji and Arabic or Indic text.
  • Non-breaking space (U+00A0): looks exactly like a normal space but is a different character. Breaks trim(), splitting on " ", and CSS that targets regular spaces.
  • BOM (U+FEFF): a byte order mark at the very start of a file. A leading BOM in JSON or a script file causes “unexpected token” errors and silent parse failures.
  • Soft hyphen (U+00AD): invisible until a word wraps, then it shows a hyphen in odd places.
  • Bidi control characters (U+202A through U+202E, U+2066 through U+2069): reorder text direction. They cause weird wrapping and have been used to hide malicious code in plain sight.

Where they sneak in

You rarely type these on purpose. They arrive when you copy text from somewhere else:

  • PDFs insert non-breaking spaces and soft hyphens during layout.
  • Word and Google Docs add non-breaking spaces and the occasional BOM on export.
  • Web pages ship zero-width spaces inside copy-protection or formatting.
  • AI output sometimes carries zero-width characters, which is one way invisible “watermarks” get embedded in generated text.

The result is text that looks identical but is not. A failed === check, a JSON file that will not parse, a CSV column that splits wrong, a line that wraps in a strange place. Hard to spot, because there is nothing to see.

How to detect and remove them

The Invisible Character Detector highlights every hidden character and names it, so you can see exactly what is there before you touch anything.

  1. Open the Invisible Character Detector.
  2. Paste the text you suspect, straight from the PDF, doc, or chat.
  3. Read the highlighted markers and the count of each character type found.
  4. Click to strip them, then copy the clean text back out.

It runs entirely in your browser, so your text never leaves your device. That matters when you are pasting in config, customer data, or anything you would not want uploaded.

  • Cleaning up extra spaces, tabs, and blank lines too? Use the Whitespace Cleaner.
  • Need to swap one specific character or string for another? Try Find & Replace.
  • Normalizing capitalization after the cleanup? See the Case Converter.

If text behaves strangely but looks perfect, an invisible character is almost always the reason. Paste it, find it, strip it.

← All posts