Why are there invisible characters in my text?
Invisible characters creep into text whenever you copy from PDFs, web pages, Word, Excel — or AI chatbots like ChatGPT. Characters such as the zero-width space (U+200B), soft hyphen (U+00AD), and bidirectional control marks have no visible glyph, but they are real characters to every computer program. They break search, spellcheck, code, and formatting the moment you paste them somewhere new.
Most were designed for typesetting — telling a layout engine where it may break a long word, or which direction mixed Arabic/English text should flow. Outside that context they are pure baggage: they make "helloworld" unfindable in search, trip up markdown parsers, and trigger mysterious syntax errors in code. The direction-switching family is the most consequential of the group, because it can make source code read differently to a human than it does to a compiler — it has its own guide on how to remove BiDi control characters.
Common invisible characters this tool removes
Zero Width Space (ZWSP)
Marks a potential word boundary. Invisibly joins words, breaking search and spellcheck.
It has legitimate uses in languages that don't use visible spaces, like Thai or Japanese. Elsewhere, a U+200B between "hello" and "world" makes "helloworld" eleven characters, not ten: searching for the word fails, and it can wrap mid-word. In code, Node reports "SyntaxError: Invalid or unexpected token", while CPython names the character — "SyntaxError: invalid non-printable character U+200B".
Byte Order Mark (BOM)
A file-encoding marker that shows up as a ghost character when pasted into web apps.
Directional Marks (LRM/RLM)
Switch text direction between left-to-right and right-to-left. Cause cursor glitches and flipped punctuation.
Soft Hyphen
An invisible hyphenation hint from PDFs and justified layouts that pollutes plain text.
It shows as a hyphen only if the line actually breaks there. Web pages write it as ­, and Word inserts one when you press Ctrl and minus. Delete it rather than replacing it with a hyphen, which would add a visible hyphen to words that were never split; in Excel, =SUBSTITUTE(A1, UNICHAR(173), ""). Keep it only in HTML or Word source you are still going to publish.
Word Joiner
Prevents line breaks without any visible width — a frequent stowaway in copied text.
Narrow No-Break Space
A thin, non-breaking space, known for a brief April 2025 appearance in o3 and o4-mini output — nearly indistinguishable from a normal space.
U+202F is the character at the centre of the ChatGPT watermark characters story. For the complete table of every character we detect — including Unicode tag characters and variation selectors — see the full invisible Unicode characters list.
Remove one specific invisible character
Each character behaves differently and has a different safe way to remove it. Start from the one you found:
- Zero-width space (U+200B), zero-width joiner (U+200D) and zero-width non-joiner (U+200C)
- Soft hyphen (U+00AD), non-breaking space (U+00A0) and narrow no-break space (U+202F)
Or start from where the text came from: PDF, Word, Google Docs or Outlook, Excel, or an AI chatbot such as ChatGPT, Copilot or Perplexity.
Why a cleaner beats find-and-replace
Paste into the box above and the report names each hidden character it removed. Unlike find-and-replace, the cleaner targets the specific Unicode ranges assigned to format and control characters, so it catches variants you'd never think to search for — while leaving legitimate characters (including emoji and non-Latin scripts) intact in the default preset. Non-breaking spaces are a slightly different case — they are real, visible-width spaces rather than zero-width ones — and the non-breaking space remover covers U+00A0 and its narrow U+202F relative in detail.
Regex to remove invisible characters (JavaScript and Python)
Zero-width spaces, word joiners, byte order marks, soft hyphens, and bidirectional controls share one Unicode general category, Cf ("Format"), so a single property escape targets the whole group:
function stripInvisible(text) {
return text
// Cf: zero-width space/joiner, BOM, soft hyphen, bidi controls, tag
// characters — except ZWNJ/ZWJ, which change spelling in some scripts.
.replace(/\p{Cf}/gu, (ch) => (ch === "\u200C" || ch === "\u200D" ? ch : ""))
// Zs: fold exotic Unicode spaces to a plain one instead of deleting them.
.replace(/\p{Zs}/gu, (ch) => (ch === " " ? ch : " "));
}The u flag is required: without it, \p{Cf} silently matches the literal text p{Cf} and no invisible character. \s is no substitute, because it matches whitespace and a zero-width space (U+200B) or word joiner (U+2060) is a format character, not whitespace. JavaScript's \s happens to include the non-breaking space (U+00A0) and the byte order mark (U+FEFF), which is why those two seem to get cleaned up for free. Python's \s matches U+00A0 but not U+FEFF, so a byte order mark survives a Python whitespace strip.
Python's built-in re module has no \p{...} syntax (it raises re.error: bad escape \p), so filter by category with the standard library, or install the third-party regex package, which accepts the same \p{Cf} syntax as JavaScript:
import unicodedata
def strip_invisible(text: str) -> str:
keep_anyway = "\u200c\u200d\t\n\r" # ZWNJ, ZWJ, and real whitespace
return "".join(
ch for ch in text
if unicodedata.category(ch) not in ("Cf", "Cc") or ch in keep_anyway
)A Cf/Zs pattern still misses two groups, so it can report clean text that still carries a payload: variation selectors (U+FE00–U+FE0F, U+E0100–U+E01EF), which are category Mn and the channel used to smuggle hidden bytes onto a character or emoji, and C0/C1 control characters (category Cc).
Before cleaning code, JSON, or CSV, keep the original input. Detect before you normalize: the cleaner above scans the untouched input first, so a U+202F or U+FEFF still shows in the report even if a later pass folds or removes it. Then choose a policy for the destination, not the source: Plain ASCII only where the target permits nothing else, join controls kept in multilingual text, and the destination's own parser or tests as the final check.