How to Tell Invisible and Zero-Width Unicode Characters Apart
Identify invisible and zero-width Unicode characters by code point, name and category, tell look-alikes apart, and clean text without breaking emoji or scripts.
Some characters take up no visible space, or look exactly like an ordinary space, but are still in your text. They can break searches, duplicate-detection, passwords, identifiers and code, and you cannot find them by looking. This guide explains which kinds of invisible Unicode characters exist, how to reveal each one by its code point, and how to tell which ones are safe to remove and which carry meaning.
What a Unicode inspector does for your text
A Unicode inspection step takes a string as input and reports every character in it as a code point (the character's number, written U+ followed by hexadecimal digits), usually together with its official Unicode name and its general category (a short code such as Cf for format characters or Zs for space separators). It does not change the text. Its output is a list that makes hidden characters explicit, so you can decide what to keep, replace or delete. Any cleanup is a separate step that should be checked against the same inspection afterward.
Four kinds of characters that look invisible
"Invisible" covers several different things. Separating them is the key to handling each correctly.
- Zero-width format characters (general category Cf): they have no width of their own but control joining, line breaking or text direction. Example: U+200B ZERO WIDTH SPACE.
- Spaces that are not the ordinary space (category Zs): they have visible width and look like U+0020 SPACE, but behave differently. Example: U+00A0 NO-BREAK SPACE.
- Blank-looking graphic characters: letters or symbols whose glyph happens to be empty. Example: U+3164 HANGUL FILLER (category Lo) and U+2800 BRAILLE PATTERN BLANK (category So). Filters that look only for spaces or format characters miss these.
- Invisible combining marks (category Mn): they attach to the preceding character without adding visible ink. Example: variation selectors U+FE00 to U+FE0F.
Unicode also defines a property called Default_Ignorable_Code_Point. It marks characters that software should display as nothing if it does not support them. It includes most zero-width format characters, the variation selectors, the soft hyphen and U+3164 HANGUL FILLER, but not U+2800 BRAILLE PATTERN BLANK or the Zs spaces. When a tool reports this property, it is a useful first signal that a character is meant to be invisible.
Common invisible and zero-width characters
| Code point | Name | Category | Intended width | What it does |
| U+200B | ZERO WIDTH SPACE | Cf | none | Marks a line-break opportunity without showing a space |
| U+200C | ZERO WIDTH NON-JOINER | Cf | none | Prevents adjacent characters from joining or forming a ligature; part of normal spelling in Persian and some Indic scripts |
| U+200D | ZERO WIDTH JOINER | Cf | none | Requests joining; also links emoji into a single combined emoji |
| U+2060 | WORD JOINER | Cf | none | Prevents a line break at that point without adding space |
| U+FEFF | ZERO WIDTH NO-BREAK SPACE (byte order mark) | Cf | none | At the start of a file or stream, signals encoding and byte order; elsewhere usually a leftover artifact |
| U+00AD | SOFT HYPHEN | Cf | none unless a line breaks there | Marks an optional hyphenation point |
| U+200E, U+200F | LEFT-TO-RIGHT MARK, RIGHT-TO-LEFT MARK | Cf | none | Influence the display order of mixed-direction text |
| U+202A to U+202E, U+2066 to U+2069 | Bidirectional embedding, override and isolate controls | Cf | none | Change the order in which text is displayed |
| U+034F | COMBINING GRAPHEME JOINER | Mn | none | Affects how combining marks are ordered and compared |
| U+FE00 to U+FE0F | VARIATION SELECTOR-1 to VARIATION SELECTOR-16 | Mn | none | Select a glyph variant; U+FE0F requests emoji-style presentation |
| U+00A0 | NO-BREAK SPACE | Zs | normal space | Space that prevents a line break |
| U+2009 | THIN SPACE | Zs | narrow | Narrow space used in typography |
| U+202F | NARROW NO-BREAK SPACE | Zs | narrow | Narrow space that prevents a line break |
| U+3000 | IDEOGRAPHIC SPACE | Zs | wide | Full-width space used in East Asian text |
| U+3164 | HANGUL FILLER | Lo | blank, often wide | Filler used in Korean text encoding; renders as empty |
| U+2800 | BRAILLE PATTERN BLANK | So | blank, one Braille cell | Empty Braille cell; renders as empty |
The width column describes intended behavior. How a character actually displays depends on the font, editor and rendering engine, so the code point, not the appearance, is the reliable identifier.
Step by step: finding and identifying a hidden character
- 1. Confirm that something is hidden. Typical signs: a string's character count is larger than what you see, the cursor needs an extra keypress to move past a spot, or an exact-match search fails on text that looks identical.
- 2. Reveal every code point using a script, a hex view or an inspector tool.
- 3. Look up each unexpected code point's name and general category.
- 4. Decide what the character is doing: formatting, spacing, joining, direction, or nothing useful.
- 5. Change only the characters you have identified as unwanted.
- 6. Run the same inspection again and compare it with the original.
Inspecting code points in Python
Python's standard unicodedata module provides names and categories. The sample string below is an example containing a zero width space and a no-break space, written with escape sequences so the hidden characters are explicit.
import unicodedata
s = "a\u200bb\u00a0c"
print(repr(s))
for ch in s:
print(f"U+{ord(ch):04X} {unicodedata.category(ch)} {unicodedata.name(ch, '<no name>')}")
Expected output, based on Unicode character data (not a captured run):
'a\u200bb\xa0c'
U+0061 Ll LATIN SMALL LETTER A
U+200B Cf ZERO WIDTH SPACE
U+0062 Ll LATIN SMALL LETTER B
U+00A0 Zs NO-BREAK SPACE
U+0063 Ll LATIN SMALL LETTER C
The repr() call is a quick check on its own: Python escapes characters it does not consider printable, which includes format characters and spaces other than U+0020, so they appear as escape sequences instead of disappearing.
Inspecting code points in JavaScript
Iterating with for...of walks the string by code point rather than by UTF-16 unit, which matters for characters above U+FFFF such as emoji and tag characters. The Unicode property escape \p{Cf} requires the u flag.
const s = "a\u200Bb";
for (const ch of s) {
console.log("U+" + ch.codePointAt(0).toString(16).toUpperCase().padStart(4, "0"));
}
console.log(/\p{Cf}/u.test(s)); // true when a format character is present
Checking raw bytes and searching files on the command line
In UTF-8, each invisible character has a fixed byte sequence, so a hex dump reveals it even when an editor hides it. Some sequences worth recognizing: U+200B is E2 80 8B, U+200C is E2 80 8C, U+200D is E2 80 8D, U+2060 is E2 81 A0, U+FEFF is EF BB BF, and U+00A0 is C2 A0. The example below uses bash's printf, which understands \u escapes in recent bash versions.
printf 'a\u200bb' | od -An -tx1
# expected: 61 e2 80 8b 62
To find lines containing common zero-width characters, GNU grep with Perl-compatible patterns can match code point ranges. This depends on grep being built with PCRE support and on a UTF-8 locale.
grep -nP '[\x{200B}-\x{200F}\x{2060}\x{FEFF}\x{00AD}]' file.txt
Telling look-alikes apart
- Zero-width character or unusual space: check the category. Cf means a format character with no width; Zs means a space separator with width.
- What \s matches: in Python, \s in a str pattern matches U+00A0 and other Zs spaces but not U+200B or U+FEFF. In JavaScript, \s matches U+00A0, the Zs spaces and U+FEFF, but not U+200B. A whitespace-trimming function therefore may leave zero-width characters behind.
- Joiner or non-joiner: U+200D requests joining and U+200C prevents it. They have opposite effects despite similar names.
- Byte order mark or mid-text artifact: U+FEFF at the very beginning of a file usually signals encoding; the same character in the middle of text usually comes from joining files or copy-and-paste.
- Blank glyph or real space: U+3164 and U+2800 are classified as a letter and a symbol, so they pass checks such as "is this string non-empty after trimming spaces". Identify them by name, not by category alone.
Removing invisible characters without damaging meaningful text
Stripping every Cf or Default_Ignorable character in one pass is the most common way to corrupt text unintentionally. Several of these characters are part of correct content:
- Emoji sequences: a family emoji is built as U+1F468, U+200D, U+1F469, U+200D, U+1F467. Removing the U+200D characters splits it into three separate emoji. Removing U+FE0F can switch an emoji to plain-text style.
- Scripts that rely on joining control: in Persian, U+200C is part of standard spelling for certain word forms, and U+200C or U+200D also affects how some Indic scripts render.
- Intentional typography: U+00A0 and U+202F are often placed on purpose, for example between a number and its unit, to stop a line break.
- Soft hyphens: U+00AD from publishing workflows is invisible until a line breaks; removing it is usually harmless for plain text but loses hyphenation hints.
- Bidirectional marks: U+200E and U+200F can be needed for correct display of mixed right-to-left and left-to-right text.
- Source code: bidirectional override and isolate controls can make code appear in a different order than the compiler reads it. In code review, flag them rather than silently deleting them, so the change is visible.
Unicode normalization does not solve this problem on its own. NFKC normalization maps compatibility spaces such as U+00A0, U+2009, U+202F and U+3000 to U+0020, but it leaves U+200B, U+200C, U+200D and U+2060 in place, and it also rewrites other characters such as full-width letters and ligatures. Use it only when that broader change is acceptable.
A safer approach is to remove an explicit list of characters you have decided are unwanted. The example below removes the zero width space, word joiner and byte order mark while deliberately keeping joiners, variation selectors and spaces with width.
import re
UNWANTED = "\u200B\u2060\uFEFF"
cleaned = re.sub(f"[{UNWANTED}]", "", text)
print(len(text), len(cleaned))
To verify the result, rerun the code point inspection on the cleaned text and confirm that only the targeted code points are gone and that the difference in length equals the number of characters you expected to remove. If the text includes emoji or right-to-left scripts, also check it visually in the application where it will be used. Python's built-in re module does not support \p{...} property classes; if you need category-based matching, use unicodedata.category() in a loop or the third-party regex module.
Limits of this guide
No tool-specific evidence was provided for this article, so it does not compare or recommend particular inspector applications or websites, and it makes no claims about their accuracy or features. The guidance relies on Unicode character properties and on documented behavior of standard language features. The code samples are illustrative, and their outputs are expected results rather than captured runs. Display of invisible characters differs between editors and fonts, so confirm behavior in the software you actually use.