Unicode Character Code: How to Identify an Invisible Character and Its Properties
Find the Unicode code point, name, category and properties of a hidden character in your text, check its bytes, and decide safely whether to keep it.
An invisible character can sit inside text and still change how it behaves. A search can fail to match. Two strings that look identical can compare as different. A line can refuse to wrap where you expect it to. Before you can deal with such a character, you need to identify it, and the standard identifier is its Unicode character code. This guide explains what that code is, how to read it from your text, how to look up the character's properties, and how to confirm the result before you change anything.
What a Unicode character code is
Unicode gives every character a number called a code point. By convention, a code point is written as U+ followed by at least four hexadecimal digits. For example, U+0041 is LATIN CAPITAL LETTER A and U+200B is ZERO WIDTH SPACE. Code points run from U+0000 to U+10FFFF. When people talk about a character's "code", "number" or "value", they usually mean this code point.
The code point is separate from the bytes stored in a file. An encoding such as UTF-8, UTF-16 or UTF-32 turns the code point into bytes or code units. The same character can therefore appear in several forms, and an inspection tool may show any of them. The table below shows the common forms for one invisible character and for one character outside the Basic Multilingual Plane. The values follow from the published encoding rules.
| Form | ZERO WIDTH SPACE | GRINNING FACE |
| Code point | U+200B | U+1F600 |
| Decimal value | 8203 | 128512 |
| UTF-8 bytes | E2 80 8B | F0 9F 98 80 |
| UTF-16 code units | 200B | D83D DE00 (surrogate pair) |
| UTF-32 | 0000200B | 0001F600 |
| HTML numeric reference | โ or โ | ๐ or ๐ |
| Python string escape | \u200b | \U0001F600 |
| JavaScript string escape | \u200B | \u{1F600} |
If a tool reports E2 80 8B, it is showing UTF-8 bytes. If it reports 8203, it is showing the decimal value. Both describe U+200B. Before you compare results from two tools, confirm which form each one displays.
What a Unicode inspection tool does for your text
A Unicode inspector takes a piece of text and breaks it into its individual code points. It reports each one in a readable form. The input can be pasted text, a file or a string in a program. The output is a list that usually includes the position, the code point, the official character name and the general category. Fuller tools also show the encoded bytes and other properties. A pure inspector does not change your text. It makes the hidden content visible so you can decide what to do with it.
Scope matters for this task. An inspector works on code points, not on what you see on screen. One visible character can consist of several code points. For example, รฉ can be the single code point U+00E9, or it can be U+0065 followed by the combining accent U+0301. Many emoji are sequences joined by U+200D ZERO WIDTH JOINER. A good inspector lists every code point separately, and that is how invisible ones become detectable.
No specific inspection tool was evaluated for this guide. Feature lists, supported Unicode versions and handling of unusual input differ between tools, so check the documentation of the one you use. The steps below rely on general, documented behavior of Unicode and of standard programming libraries.
Step by step: find the code and properties of a detected character
Step 1: Capture the text without altering it
Work from the original source whenever you can, such as the file, the database value or the raw request body. Copying and pasting through rich-text editors, chat apps or web forms can drop, replace or normalize invisible characters. In that case you end up inspecting something other than the original. If you have to paste, paste into a plain-text editor or straight into the inspection tool. Reading the file directly is more reliable.
Step 2: List the code points
Python's standard library includes the unicodedata module, which reads the Unicode Character Database bundled with Python. The example below writes the invisible characters as escapes, so you can see exactly what is in the string.
import unicodedata
text = 'a\u200bb\u00a0c'
for index, ch in enumerate(text):
code = f'U+{ord(ch):04X}'
category = unicodedata.category(ch)
name = unicodedata.name(ch, '<no name>')
print(index, code, category, name)
Expected output, derived from the character data and not run for this article:
0 U+0061 Ll LATIN SMALL LETTER A
1 U+200B Cf ZERO WIDTH SPACE
2 U+0062 Ll LATIN SMALL LETTER B
3 U+00A0 Zs NO-BREAK SPACE
4 U+0063 Ll LATIN SMALL LETTER C
Some characters have no name in this lookup. Control characters such as tab (U+0009) and unassigned code points are examples. That is why the example passes a default value to unicodedata.name. Without the default, the call raises a ValueError for those characters.
To scan a whole file, read it with an explicit encoding. Pass newline='' so Python keeps carriage returns instead of quietly converting line endings. The following illustrative script reports characters in the control, format, private-use, unassigned and separator categories. It skips the ordinary space and the line feed.
import sys
import unicodedata
SUSPECT = {'Cc', 'Cf', 'Co', 'Cn', 'Zs', 'Zl', 'Zp'}
with open(sys.argv[1], encoding='utf-8', newline='') as f:
for line_no, line in enumerate(f, start=1):
for col, ch in enumerate(line, start=1):
if ch in ' \n':
continue
cat = unicodedata.category(ch)
if cat in SUSPECT:
name = unicodedata.name(ch, '<no name>')
print(f'line {line_no}, col {col}: U+{ord(ch):04X} {cat} {name}')
There are some limits to keep in mind:
- The column number counts code points, not on-screen positions.
- Tabs and carriage returns are reported because they are control characters, though they are often harmless.
- A byte order mark at the start of the file is reported as U+FEFF, because the encoding is utf-8 rather than utf-8-sig.
- If the file is not valid UTF-8, Python raises UnicodeDecodeError. Treat that as a finding in its own right.
- Characters in the Mn (nonspacing mark) category, such as U+034F COMBINING GRAPHEME JOINER and the variation selectors, are not flagged. Add Mn to the set if you need them, but expect noise from ordinary accents.
In JavaScript, iterate with for...of so that characters outside the Basic Multilingual Plane are handled as whole code points. Use codePointAt to get the number. JavaScript has no built-in lookup for character names, so you need another source for those.
const text = 'a\u200Bb';
for (const ch of text) {
const hex = ch.codePointAt(0).toString(16).toUpperCase().padStart(4, '0');
console.log('U+' + hex);
}
Engines that support Unicode property escapes can match whole categories in a regular expression with the u flag. For example, /\p{Cf}/gu matches every format character. The same idea applies in other regex engines that support Unicode properties, though the syntax varies.
Step 3: Look up the properties that explain the behavior
Once you have the code point, its properties tell you why it behaves the way it does. These properties are most useful when investigating invisible characters:
- Name: the official, stable identifier, such as ZERO WIDTH NO-BREAK SPACE.
- General_Category: a two-letter class, such as Cf for format characters or Zs for space separators.
- Default_Ignorable_Code_Point: marks characters that renderers usually display as nothing when they have no special handling for them. Most zero-width characters have this property.
- White_Space: indicates whether the character counts as whitespace. U+00A0 does, but U+200B does not. This is why some trimming functions remove one and leave the other.
- Bidi_Class: governs right-to-left and left-to-right layout. Directional marks, embeddings and isolates (U+200E, U+200F, U+202A to U+202E, U+2066 to U+2069) can make the displayed order differ from the stored order.
- Script and Block: show which writing system or range the character belongs to. This helps you spot look-alike letters from another script.
- Decomposition: shows whether normalization will change the character. For example, NFKC normalization turns U+00A0 into an ordinary space.
- Age: the Unicode version in which the character was assigned.
Python exposes several of these directly, including unicodedata.category, unicodedata.bidirectional, unicodedata.combining, unicodedata.east_asian_width and unicodedata.decomposition. Others, such as Default_Ignorable_Code_Point, Script and Age, are not available in the standard module. Look those up in the Unicode Character Database files or with a dedicated library or inspector.
Step 4: Confirm with the raw bytes
A byte dump is independent of any editor or font, so it is a good cross-check. On Unix-like systems, od can print every byte of a file in hexadecimal:
od -An -tx1 suspect.txt
You can also test a known sample. This command writes 'a', then ZERO WIDTH SPACE as octal byte escapes, then 'b':
printf 'a\342\200\213b' | od -An -tx1
Based on the UTF-8 encoding of U+200B, the output should show the bytes 61 e2 80 8b 62. If you find the same three-byte sequence in your file's dump, that confirms the code point your inspector reported. Where GNU grep is built with PCRE support and runs in a UTF-8 locale, grep -nP '\x{200B}' suspect.txt lists the lines that contain the character.
Step 5: Check against the Unicode Character Database
The Unicode Character Database (UCD) is the authoritative set of data files published by the Unicode Consortium. Libraries and inspectors are built from it. The files most relevant here are:
- UnicodeData.txt: name, general category, canonical combining class, bidi class and decomposition.
- PropList.txt: binary properties such as White_Space.
- DerivedCoreProperties.txt: derived properties such as Default_Ignorable_Code_Point.
- Scripts.txt and Blocks.txt: script and block assignments.
- DerivedAge.txt: the version in which each character was assigned.
Properties of assigned characters are mostly stable, but some do change between Unicode versions, and new characters are added in each release. Tools can give different answers if they bundle different versions of the data. In Python, unicodedata.unidata_version shows which version your installation uses. A character reported as Cn (unassigned) may simply be newer than the data your tool knows about.
Unicode general categories at a glance
The general category is the quickest way to sort what you found. The first letter gives the broad class and the second letter refines it. These are the categories that matter most when looking for invisible content:
| Category | Meaning | Examples |
| Cc | Control | U+0009 tab, U+000D carriage return |
| Cf | Format: affects layout or processing, usually has no glyph | U+200B, U+200D, U+FEFF, U+00AD, U+200E |
| Zs | Space separator | U+0020 space, U+00A0 no-break space, U+3000 ideographic space |
| Zl | Line separator | U+2028 |
| Zp | Paragraph separator | U+2029 |
| Mn | Nonspacing mark: combines with the preceding character | U+0301 combining acute accent, U+FE0F variation selector-16 |
| Co | Private use: meaning defined by agreement, not by Unicode | Any code point in a private-use area |
| Cn | Unassigned or noncharacter | Code points with no assigned character in the tool's data version |
The other categories cover visible content. Letters are L*, numbers are N*, punctuation is P* and symbols are S*. Cs (surrogate) should never appear as a standalone character in well-formed text. If it does, the text was probably mis-decoded or split in the middle of a UTF-16 surrogate pair.
Common invisible and look-alike characters
| Code point | Name | Category | UTF-8 bytes | Typical role |
| U+00A0 | NO-BREAK SPACE | Zs | C2 A0 | Space that prevents a line break; often comes from web pages and word processors |
| U+00AD | SOFT HYPHEN | Cf | C2 AD | Marks an optional hyphenation point; usually invisible |
| U+200B | ZERO WIDTH SPACE | Cf | E2 80 8B | Marks a possible line-break point with no visible width |
| U+200C | ZERO WIDTH NON-JOINER | Cf | E2 80 8C | Prevents letters from joining; meaningful in Persian, Indic and other scripts |
| U+200D | ZERO WIDTH JOINER | Cf | E2 80 8D | Requests joining; used in emoji sequences and some scripts |
| U+200E | LEFT-TO-RIGHT MARK | Cf | E2 80 8E | Influences bidirectional layout |
| U+200F | RIGHT-TO-LEFT MARK | Cf | E2 80 8F | Influences bidirectional layout |
| U+202F | NARROW NO-BREAK SPACE | Zs | E2 80 AF | Narrow non-breaking space, used in some number and date formats |
| U+2060 | WORD JOINER | Cf | E2 81 A0 | Prevents a line break without adding width |
| U+FEFF | ZERO WIDTH NO-BREAK SPACE | Cf | EF BB BF | Byte order mark at the start of a file; a stray, invisible character elsewhere |
| U+034F | COMBINING GRAPHEME JOINER | Mn | CD 8F | Affects sorting and normalization; no visible form |
| U+FE0F | VARIATION SELECTOR-16 | Mn | EF B8 8F | Requests emoji-style presentation of the preceding character |
Pitfalls that lead to wrong answers
- String length is not the character count. In JavaScript, '\u{1F600}'.length is 2 because the string length counts UTF-16 code units. Use code-point iteration when you report positions.
- The text may be decoded with the wrong encoding. If UTF-8 bytes are read as a legacy single-byte encoding, U+200B can appear as three odd symbols such as รขโฌโน. You would then be inspecting the mis-decoded characters, not the original one.
- Normalization can run before you look. Some editors and pipelines apply NFC or NFKC normalization, which can merge, split or replace characters. Inspect before any normalization step.
- A font may display a placeholder glyph. A visible box or dotted shape tells you nothing about the code point. Rely on the reported number, not on how the character looks.
- The data version may differ. Two tools can disagree about a recently added character. Compare the Unicode versions they use.
Deciding what to do with what you found
Identifying a character does not mean you should delete it. Some invisible characters carry meaning. ZERO WIDTH JOINER holds multi-part emoji together, and removing it splits them into separate pictures. ZERO WIDTH NON-JOINER changes how words are spelled and shaped in several scripts. Directional marks can be required for correct display of mixed right-to-left and left-to-right text. Variation selectors control whether a symbol is shown in text style or emoji style. A no-break space may have been placed deliberately to keep a number with its unit.
Characters that are usually safe to target include a byte order mark in the middle of a string, zero width spaces that came from copied web content, and soft hyphens in data fields such as identifiers or codes. Even then, limit the change to the exact code points you identified. Avoid broad patterns such as "all non-ASCII", which also strip accents,non-Latin scripts and symbols that belong in the text.
Replacement is sometimes better than removal. Changing U+00A0 to U+0020 keeps the gap between words while making the space an ordinary one. Removing U+200B outright is usually correct, because it adds no visible width.
import re
text = 'price\u00a0list\u200b'
cleaned = text.replace('\u00a0', ' ')
cleaned = re.sub('[\u200b\ufeff]', '', cleaned)
print(repr(cleaned))
In this illustrative example, which was not run for this article, the expected printed value is 'price list'. The no-break space becomes a regular space, the zero width space is removed, and everything else is left alone.
Verify the result
After any change, run the same inspection again and compare the result with the first one:
- The code points you meant to remove or replace no longer appear.
- No other code points have disappeared or changed. A count of characters by category before and after makes unexpected losses easy to spot.
- The byte dump no longer contains the targeted sequences, such as E2 80 8B for U+200B.
- The original problem is gone: the search matches, the strings compare equal, or the line wraps as expected.
- Text that relies on joiners, non-joiners, directional marks or variation selectors still displays correctly.
If a check fails, go back to the step-one capture of the original text and adjust the change, rather than patching the already modified copy. This keeps meaningful content intact and makes it easy to show exactly which characters were affected.