Identify zero-width characters in Unicode text
How to find zero-width characters such as U+200B, U+200C, U+200D, U+2060 and U+FEFF, what removing them changes, and when stripping them is safe.
A zero-width character is a real Unicode character that takes up no horizontal space when rendered. It sits in the stored text, survives most copy-and-paste operations and affects searching, comparison and parsing, but you usually cannot see it. Identifying these characters means inspecting the text at the code point level instead of trusting what appears on screen. This review covers what that inspection reveals, what removing or inserting these characters changes, and when the transformation fits your purpose.
Is identifying or removing zero-width characters right for your use?
Inspection is low risk because it only reports what is already in the text. Removal is a real transformation. Its main benefit is clean, predictable data: identifiers, usernames, URLs, code, spreadsheet keys and search terms then match what they appear to say. The decisive tradeoff is that some zero-width characters carry meaning. Stripping them can break emoji sequences, change how words are spelled in some writing systems, or alter text direction.
Removal is generally appropriate for machine-oriented strings such as variable names, file names, email fields, database keys and configuration values. Natural-language text needs a more selective approach, especially in Persian, Arabic, Indic scripts or anything containing emoji, where you should review each match. Inserting zero-width characters to make text look blank, defeat filters or break automatic linking is rarely a good choice. Plain text is preferable whenever other people, search tools or assistive technology need to process the content reliably.
What these characters are and what a transformation changes
Most characters people mean by "zero width" belong to the Unicode general category Cf, the format characters. They control joining, line breaking or direction rather than representing a visible letter. Tools that reveal them change only how the text is presented, for example by drawing a marker or showing the code point. Tools that remove or insert them change the stored characters themselves. Keep the two distinct: a text that looks identical before and after editing may still differ underneath, and a highlighted marker does not mean anything has been removed.
| Code point | Name | Typical role | Effect of removing it |
| U+200B | ZERO WIDTH SPACE | Marks an optional line-break point without a visible space | Usually safe in data; may change line wrapping in long words or URLs |
| U+200C | ZERO WIDTH NON-JOINER | Prevents adjacent letters from joining, used in Persian and some Indic scripts | Can change spelling or letter forms in those languages |
| U+200D | ZERO WIDTH JOINER | Requests joining; links emoji into a single sequence | Splits combined emoji into separate symbols and can change Indic conjunct forms |
| U+2060 | WORD JOINER | Prevents a line break at that position | Usually safe in data; may allow unwanted line breaks |
| U+FEFF | ZERO WIDTH NO-BREAK SPACE, also used as a byte order mark | At the start of a file, signals encoding; elsewhere, a legacy no-break marker | Often desirable at the start of data files; check whether the consuming program expects it |
| U+200E and U+200F | LEFT-TO-RIGHT MARK and RIGHT-TO-LEFT MARK | Influence the display order of neutral characters in bidirectional text | Can change the displayed order of punctuation and numbers near right-to-left text |
| U+00AD | SOFT HYPHEN | Marks where a word may be hyphenated; visible only at a line break | May remove hyphenation hints |
Some related characters are invisible but not strictly zero-width, such as the bidirectional embedding, override and isolate controls (U+202A to U+202E and U+2066 to U+2069), variation selectors (U+FE00 to U+FE0F) and the combining grapheme joiner (U+034F). A thorough inspection should report them too, because they affect display or comparison in similar ways.
A concrete example shows why blanket removal is risky. The woman technologist emoji is stored as three code points: U+1F469 (woman), U+200D (zero width joiner) and U+1F4BB (personal computer). Remove the joiner and many renderers show a woman and a laptop side by side. The same issue affects reverse-text tools: if a tool reverses code points rather than whole grapheme clusters, the joiner ends up in the wrong position and the emoji falls apart, and combining accent marks detach from their base letters.
How to identify zero-width characters
Reliable identification means listing every character with its code point and Unicode name. The following Python snippet prints the position, code point and name of every format character in a string. It uses only the standard library.
import unicodedata
text = "paste or load your text here"
for i, ch in enumerate(text):
if unicodedata.category(ch) == "Cf":
print(i, f"U+{ord(ch):04X}", unicodedata.name(ch, "<unnamed>"))
For a narrower search, a regular expression can target the most common zero-width characters. In JavaScript, the character class below matches U+200B, U+200C, U+200D, U+2060 and U+FEFF. Note that JavaScript's whitespace class \s matches U+FEFF but not U+200B, so trimming or whitespace matching alone will not catch every zero-width character.
const zeroWidth = /[\u200B-\u200D\u2060\uFEFF]/g;
const found = [...text.matchAll(zeroWidth)].map(m => ({
index: m.index,
codePoint: "U+" + m[0].codePointAt(0).toString(16).toUpperCase().padStart(4, "0")
}));
At the byte level, UTF-8 files show these characters as recognizable sequences in a hex dump: E2 80 8B for U+200B, E2 80 8C for U+200C, E2 80 8D for U+200D, E2 81 A0 for U+2060 and EF BB BF for U+FEFF. Seeing EF BB BF at the very start of a file usually indicates a byte order mark.
Common symptoms that suggest a hidden character is present:
- Two strings look identical but do not compare as equal.
- A search fails to find a word that is visibly on the page.
- The cursor needs an extra keypress to move past a spot that looks empty.
- A string's reported length is longer than the number of visible characters.
- A script, CSV header or configuration key fails only on the first line or first column.
- Punctuation or numbers appear in an unexpected order next to right-to-left text.
Will the text stay readable and usable after copying or sharing?
Zero-width characters are part of the text, so they normally travel with it through copy and paste. Whether a particular destination keeps, strips or normalizes them depends on that application, and no tested results for specific destinations were supplied for this review. If it matters, paste a sample into the actual destination and inspect it again.
- Search and matching: a word with an embedded zero-width space no longer matches the plain word, which can hide content from search or let it slip past keyword filters.
- Editing: hidden characters cause confusing cursor movement and can break find-and-replace.
- Code and data: an invisible character in an identifier, URL, password field or file name produces errors that are hard to diagnose, and a byte order mark can break scripts or headers that expect plain text at the start of a file.
- Reading order: directional marks and controls can change how mixed-direction text is displayed, so the visible order may differ from the stored order.
- Hidden content: sequences of invisible characters can encode marks or data inside otherwise ordinary text, so inspect copied text before sharing it in sensitive contexts.
Assistive technology is a gap in the available evidence. How screen readers announce, skip or stumble over zero-width characters varies, and no documentation or scoped test results were supplied here. Do not assume one result applies everywhere. When content must be accessible, provide a plain-text version without decorative or filler zero-width characters, and keep only those required for correct spelling or emoji.
Finding a tool or setting to reveal them
Useful search terms include "Unicode inspector", "code point viewer", "invisible character detector", "show invisible Unicode characters" and the specific character name, such as "zero width space U+200B". Many code editors and text processors can highlight invisible or unusual Unicode characters, but menu names and default settings differ between products and versions, and no specific tools or navigation paths were verified for this review. When choosing a tool, prefer one that shows the code point and official name, not just a generic marker, so you can tell a meaningful joiner from a stray space. If you paste sensitive text into an online tool, check its stated data handling first, because the tool's appearance says nothing reliable about what it stores.
Bottom line
Inspect first, then decide. Removing zero-width characters is a sound choice for data, code and identifiers, where invisible differences cause real failures. In human-language text, review matches individually, preserving joiners in emoji and non-joiners and joiners in scripts that rely on them. Where readers, search tools or assistive technology need reliable text, plain text without decorative invisible characters is the safer default.