How to Detect and Identify Invisible Unicode Characters in Text
Use a Unicode detector to find and identify zero-width spaces, byte order marks and direction marks in text, then clean them without changing meaning.
Text that looks perfectly normal can contain characters you cannot see. They have no visible shape, take up no width or look exactly like an ordinary space. These hidden characters can still break searches, logins, spreadsheet formulas and source code. A Unicode detector, also called a Unicode character checker or identifier, shows what is really in the text by listing every character it contains. This guide explains what such a tool does, which invisible characters to look for, and how to find, identify and handle them without damaging text that needs them.
What a Unicode character detector does for your text
A Unicode detector takes text as input. You can usually paste a string or load a file. The tool splits the text into code points. A code point is the number Unicode assigns to each character, written as U+ followed by hexadecimal digits, for example U+200B. The tool then looks up each code point in the Unicode Character Database.
The output is a character-by-character report. Depending on the tool, each entry typically includes the code point, the official character name, the general category, and sometimes the encoded bytes in UTF-8 or UTF-16. Inspection is read-only. The detector changes nothing in your text unless you separately use a cleaning or replacement feature.
The scope is identification. A detector tells you what a character is, but not whether it belongs there. Deciding whether to keep, replace or remove each character is up to you, and the section on safe removal below covers how to make that call.
Keep in mind that what appears to be one character on screen can be several code points. For example, some emoji are sequences joined by invisible characters, and an accented letter such as é can be stored as one precomposed code point (U+00E9) or as a plain e followed by a combining accent (U+0065 U+0301). A code-point-level detector lists each part separately, which is exactly what makes hidden content visible.
Invisible characters you are most likely to find
The general category in a detector's report is a short code that tells you what kind of character you are looking at. The categories that matter most here are Cf (format character, usually invisible), Zs (space separator), Zl and Zp (line and paragraph separators), Cc (control character) and Mn (nonspacing mark, which attaches to the previous character).
| Code point | Name | Category | What it does or where it comes from |
| U+00A0 | NO-BREAK SPACE | Zs | Looks like a normal space but prevents a line break; common in text copied from web pages and word processors |
| U+00AD | SOFT HYPHEN | Cf | Invisible unless a word breaks at the end of a line, where it shows as a hyphen |
| U+200B | ZERO WIDTH SPACE | Cf | Marks a possible line break with no visible width |
| U+200C | ZERO WIDTH NON-JOINER | Cf | Prevents neighboring letters from joining; required for correct spelling in some scripts, such as Persian |
| U+200D | ZERO WIDTH JOINER | Cf | Joins characters; used to build many multi-part emoji |
| U+200E and U+200F | LEFT-TO-RIGHT MARK, RIGHT-TO-LEFT MARK | Cf | Influence text direction in mixed left-to-right and right-to-left text |
| U+202A to U+202E | Bidirectional embeddings and overrides | Cf | Can change the displayed order of characters |
| U+2066 to U+2069 | Bidirectional isolates | Cf | Isolate a run of text for direction handling |
| U+2028 and U+2029 | LINE SEPARATOR, PARAGRAPH SEPARATOR | Zl, Zp | Act as line or paragraph breaks; some software does not treat them as normal newlines |
| U+2060 | WORD JOINER | Cf | Prevents a line break with no visible width |
| U+FEFF | ZERO WIDTH NO-BREAK SPACE (byte order mark) | Cf | Often appears at the very start of a file as a byte order mark (BOM) |
| U+FE00 to U+FE0F | VARIATION SELECTORS | Mn | Choose a presentation style, for example text-style or emoji-style display |
| U+E0000 to U+E007F | TAG characters | Cf | Invisible; used in some emoji flag sequences |
| U+3164 | HANGUL FILLER | Lo | Renders blank but is categorized as a letter, so category-based filters miss it |
Why hidden characters cause problems
- Searches and comparisons fail: the example string pay[U+200B]pal looks like paypal on screen but does not match it.
- Form validation and logins break when a username or password silently includes a zero-width or no-break character.
- Spreadsheet data looks duplicated or fails to match because one cell contains U+00A0 instead of a regular space.
- Splitting text on spaces misses no-break spaces, so words stay glued together.
- A byte order mark at the start of a script, configuration file or data file can cause parse errors in tools that do not expect it.
- Bidirectional override characters can make source code display in a different order than the compiler or interpreter reads it. This risk was publicly described in 2021 under the name Trojan Source.
Step by step: detect and identify invisible characters
- 1. Capture the exact text. Copy it directly from its source instead of retyping it. Some editors, chat apps and web forms normalize or strip characters on paste, so check the original file or raw data when you can.
- 2. Run a detector. Use an online Unicode character checker, a feature in your code editor, or a short script (examples below).
- 3. Read each flagged entry. Note the position, code point, name and category of every character that is not a visible letter, digit, punctuation mark or ordinary space.
- 4. Decide what each character is doing. Use the table above and the safe-removal guidance below to separate accidental characters from meaningful ones.
- 5. Verify the result. After any change, run the detector again and confirm that only the characters you intended to keep remain.
A quick first check is to compare length. If a program reports more characters than you can count on screen, something hidden is present. A length check only tells you that something is there, so follow it with a full character listing.
Option 1: Inspect with a short Python script
Python's standard unicodedata module provides character names and categories, so you can build a basic Unicode character identifier without extra packages. The example below flags format, control and separator characters, skips the ordinary space, tab and newline characters, and adds the Hangul Filler explicitly because its category is a letter.
import unicodedata
SUSPECT_CATEGORIES = {"Cf", "Cc", "Zs", "Zl", "Zp"}
ALLOWED = {" ", "\t", "\n", "\r"}
def find_hidden(text):
for index, ch in enumerate(text):
if ch in ALLOWED:
continue
category = unicodedata.category(ch)
if category in SUSPECT_CATEGORIES or ch == "\u3164":
name = unicodedata.name(ch, "<no name>")
print(f"{index} U+{ord(ch):04X} {category} {name}")
find_hidden("pay\u200bpal\u00a0login")
Illustrative output. This is what the script is written to print for the sample string and is shown here as an example, not as a captured test run:
3 U+200B Cf ZERO WIDTH SPACE
7 U+00A0 Zs NO-BREAK SPACE
The script does not flag variation selectors (U+FE00 to U+FE0F) because they are in category Mn along with many visible accents. If you need them, add an explicit range check. Also note that Python's names reflect the Unicode version bundled with your Python release, so very new characters may show as <no name>.
Option 2: Search files from the command line
With a grep build that supports Perl-compatible regular expressions, such as GNU grep, you can list the lines that contain common invisible characters. This requires a UTF-8 locale, and support for the -P option varies by system.
LC_ALL=C.UTF-8 grep -nP '[\x{00A0}\x{00AD}\x{200B}-\x{200F}\x{202A}-\x{202E}\x{2060}-\x{2064}\x{2066}-\x{2069}\x{FEFF}]' file.txt
To see the raw bytes, open the file in a hex viewer such as xxd and look for the UTF-8 byte sequences of the suspects. For example, U+200B is E2 80 8B, U+200C is E2 80 8C, U+200D is E2 80 8D, U+202E is E2 80 AE, U+FEFF is EF BB BF, U+00A0 is C2 A0, and U+00AD is C2 AD. A file that begins with EF BB BF starts with a UTF-8 byte order mark.
Option 3: Use your editor or an online checker
Many code editors can render whitespace visibly or highlight unusual and invisible Unicode characters. Look in the editor's settings for whitespace rendering or Unicode highlighting options, since names and defaults differ between editors. Online Unicode character lookup tools are convenient for short strings. Avoid pasting passwords, tokens or confidential text into a third-party website, because anything you submit leaves your machine.
Removing or replacing characters without changing meaning
Some invisible characters are mistakes, and others carry meaning. Deleting a whole category at once is the most common way cleanup goes wrong. Target specific code points that you have identified as unwanted in your context.
- Zero width joiner (U+200D): do not remove it from emoji. Many emoji sequences depend on it, and removing it can split one emoji into several.
- Zero width non-joiner (U+200C): keep it in scripts that use it for correct spelling, such as Persian.
- Variation selectors (U+FE00 to U+FE0F): removing them can change how a symbol displays, for example from emoji style to text style.
- No-break space (U+00A0): replacing it with a regular space is usually safe for data matching. In typeset text, though, it may be deliberately keeping a number together with its unit or a title together with a name.
- Soft hyphen (U+00AD): it is often intentional in text prepared for hyphenation, but it is usually unwanted in identifiers, URLs inside text or data fields.
- Direction marks and isolates: they may be legitimate in mixed left-to-right and right-to-left text. Bidirectional overrides and embeddings in source code deserve close review.
- Byte order mark (U+FEFF): at the start of a UTF-8 file, it can usually be removed if the tools that read the file do not need it. Anywhere else in the text, it is almost always accidental.
Here is an example of targeted cleanup in Python. It removes only the zero width space, word joiner and byte order mark, and it converts no-break spaces to regular spaces. Adjust both lists to match what your inspection actually found.
REMOVE = {"\u200b", "\u2060", "\ufeff"}
cleaned = "".join(ch for ch in text if ch not in REMOVE)
cleaned = cleaned.replace("\u00a0", " ")
Keep an unmodified copy of the original before cleaning. Afterward, run the detector on the result and confirm two things: no unwanted characters remain, and the change in length matches the number of characters you meant to remove. A side-by-side diff of the original and cleaned versions shows whether anything else changed.
Limits to be aware of
- A detector is only as current as its Unicode data. Characters added in newer Unicode versions may appear as unassigned or unnamed in older tools.
- Category-based filters miss characters such as U+3164 HANGUL FILLER, which renders blank but is classified as a letter. A careful check combines category rules with an explicit list of known blank characters.
- Lookalike characters are visible but deceptive, for example Cyrillic а (U+0430) in place of Latin a (U+0061). A character listing exposes them through their different names and code points, even though they are not invisible.
- Copying and pasting can alter text before it reaches the detector, so inspect the original file or data source when the exact content matters.
- This guide does not evaluate or compare specific detector products. No tested comparison of tools was available, so choose a tool based on whether it shows code points, names and categories for every character.