What Are Zero-Width Space Characters in Plain Text?
You copy a string from a documentation website, an API payload, or an AI chat window. You paste it into your code editor or run a SQL query. The code looks completely pristine on your screen:
SELECT * FROM users WHERE email = '[email protected]'; -- Error: Syntax error or 0 rows returned!
You re-read the query five times. The spelling is exact. There are no missing quotes. Yet the database insists there is a syntax error, or your JavaScript script outputs false when comparing two seemingly identical strings:
"[email protected]" === "[email protected]" // false!
You have just encountered an invisible character—most commonly the Zero-Width Space (U+200B).
Which Unicode Code Points Are Zero-Width Characters?
Unicode includes several characters specifically engineered to carry zero visual width:
| Character Name | Unicode Codepoint | UTF-8 Bytes | Intended Typographic Purpose |
|---|---|---|---|
| Zero-Width Space (ZWSP) | U+200B |
E2 80 8B (3 bytes) |
Indicates a permissible line break point without inserting a space or hyphen |
| Zero-Width Non-Joiner (ZWNJ) | U+200C |
E2 80 8C (3 bytes) |
Prevents two Arabic, Persian, or Indic letters from connecting into a ligature |
| Zero-Width Joiner (ZWJ) | U+200D |
E2 80 8D (3 bytes) |
Glues emoji components together (e.g. 👨 + ZWJ + 💻 = 👨💻) |
| Byte Order Mark (BOM) | U+FEFF |
EF BB BF (3 bytes) |
Historically marked endianness at the start of text files |
| Word Joiner | U+2060 |
E2 81 A0 (3 bytes) |
Prevents a line break between two characters without adding space |
How Do Zero-Width Characters Get Into Copy-Pasted Text?
You rarely type a zero-width space intentionally. Instead, they sneak into your text through three primary vectors:
1. Web Typography & Justification Engines
Modern responsive websites insert <wbr> tags or U+200B characters inside long URLs, chemical formulas, and technical identifiers so mobile browsers can break lines neatly without overflowing containers. When you highlight and copy that text, your clipboard grabs the invisible breaking byte along with the letters.
2. AI Chatbot Output & Markdown Parsers
LLM interfaces and markdown rendering engines frequently generate zero-width spaces to escape reserved markdown characters or prevent unwanted autolinking in code blocks. Copying raw responses from browser chat windows regularly imports these hidden codepoints.
3. Digital Watermarking & Tracking
Some enterprise security systems, paywalled publications, and leaking-detection tools encode invisible binary sequences (steganography) into copied text using combinations of U+200B and U+200C. When an employee copies sensitive text and pastes it publicly, the invisible bit pattern reveals their user ID.
Why Do Zero-Width Characters Break Code, SQL Queries, and URLs?
To a human reading a screen, "admin" and "admin" look identical. To a computer system, they are completely different binary structures:
"admin"= 5 characters, 5 bytes (61 64 6D 69 6E)"admin"= 6 characters, 8 bytes (61 64 E2 80 8B 6D 69 6E)
The Severe Consequences:
- Authentication Bypass / Impersonation: An attacker registers a username like
admin(with a trailing U+200B). If the database enforces uniqueness without sanitizing hidden characters, both accounts exist simultaneously, opening phishing doors. - JSON Parsing Failures: Unescaped control characters or hidden non-printing bytes inside JSON string literals cause
JSON.parse()to throw immediate unexpected token errors. - Failed Regular Expressions: A regex like
/^[a-zA-Z0-9]+$/fails on an apparently valid alphanumeric string becauseU+200Bdoes not match the character class.
How Do You Detect and Remove Zero-Width Spaces Instantly?
Option 1: Using Text Cleaner (Instant Browser Tool)
Paste your suspect text into our Remove Invisible Characters Tool. The tool highlights all hidden zero-width spaces, BOMs, and soft hyphens in red, shows their exact Unicode codepoints, and strips them with a single click.
Option 2: In JavaScript / TypeScript
// Strips ZWSP, ZWNJ, ZWJ, and BOM const cleanString = dirtyString.replace(/[\u200B-\u200D\uFEFF]/g, '');
Option 3: In Python
import re clean_text = re.sub(r'[\u200b-\u200d\ufeff]', '', dirty_text)
Frequently Asked Questions
How can I see if my text has zero-width characters?
In modern text editors like VS Code, zero-width characters are highlighted with a small gray outline or box. Alternatively, check the character count: if a 5-letter word shows a length of 6 in your programming console or word counter, an invisible byte is present.
Does a standard trim() function remove zero-width spaces?
No! Standard trim functions in JavaScript, Python, PHP, and SQL only remove standard ASCII whitespace characters (spaces, tabs, newlines, carriage returns). Because U+200B is classified as a format character (category Cf) rather than whitespace (category Zs), trim() completely ignores it.
Can zero-width spaces affect Google Search SEO?
If zero-width spaces accidentally slip into your URL slugs or meta title tags, search engine crawlers index them as literal byte values. This can prevent search engines from recognizing keywords and cause 404 errors when visitors type clean URLs.
Why does deleting a zero-width space require two backspaces?
Because the cursor cannot render inside a zero-width character, the first press of the Backspace key deletes the invisible character without moving the visible cursor position on screen. The second backspace then deletes the visible preceding letter.