Invisible Whitespace & Zero-Width Space Cleaner
Detect, visualize, and strip hidden Unicode characters, zero-width spaces, BOM markers, and BiDi overrides in real time.
Raw Input & Diagnostic Visualizer
Colored badges highlight exact Unicode points that are otherwise 100% invisible on your screen.
Sanitization Engine & Output
Understanding Zero-Width Characters and Invisible Whitespace Anomalies
Modern text processing relies heavily on Unicode, an expansive character encoding standard comprising over 149,000 discrete symbols. While Unicode enables worldwide multilingual software engineering, it also introduces dozens of invisible formatting markers, zero-width joiners, non-breaking spacers, and bidirectional control codes. When these non-printing characters find their way into source code, database queries, authentication credentials, or REST API payloads, they create silent failures that elude traditional visual debugging.
Because zero-width characters occupy zero visual width in standard user interfaces and text editors, a string such as "admin\u200B" appears completely identical to "admin" on screen. However, at the byte and binary level, their hash digests, memory representations, and string lengths differ completely. A strict equality check (userRole === "admin") evaluates to false, causing inexplicable logic bypasses, broken routing parameters, and corrupted JSON schemas.
JSON & YAML Serialization Fails
Invisible Byte Order Marks (U+FEFF) and control characters at the beginning of payload strings cause parser crashes (e.g., Unexpected token at position 0).
Database Key Mismatches
Zero-width characters inside unique columns or foreign keys lead to duplicate records, broken SQL indexing, and failed join lookups across relational tables.
API Key & Hash Corruption
Secret API tokens, JWT signatures, and SHA-256 cryptographic hashes copied from formatted documentation frequently carry invisible NBSP characters that invalidate authentication.
Comprehensive Unicode Invisible & Special Whitespace Matrix
The reference table below catalogs the most prevalent invisible Unicode code points, their standard typographic intentions, and their typical software engineering failure modes:
| Unicode Code | Character Name | Visual Appearance | Intended Typographic Role | Common Bug / Failure Mode |
|---|---|---|---|---|
| U+200B | Zero-Width Space (ZWSP) | 0px width (Invisible) | Soft line-wrap break indicator | Breaks strict string comparisons, SQL WHERE matching, regex parsing |
| U+FEFF | Byte Order Mark / ZWNBSP | 0px width (Invisible) | Byte endianness declaration in UTF-16 | Fatal JSON parse exceptions, shell script header compilation errors |
| U+00A0 | Non-Breaking Space (NBSP) | 1 standard space width | Prevents line breaks between paired words | CLI command execution failures (e.g., command not found in Bash) |
| U+200C | Zero-Width Non-Joiner (ZWNJ) | 0px width (Invisible) | Suppresses cursive ligatures in Persian/Arabic | Mismatches in URL slugs, slugification algorithms, and email addresses |
| U+200D | Zero-Width Joiner (ZWJ) | 0px width (Invisible) | Combines multiple glyphs into single emojis | Unexpected string length counts in SMS/Twitter character limits |
| U+202E | Right-to-Left Override (RLO) | 0px width (Invisible) | Reverses text visual rendering direction | Trojan Source code obfuscation (disguises executable code as comments) |
| U+3000 | Ideographic Space | 2 standard spaces width | Full-width alignment in CJK typography | Breaks monospace tabular column alignment in terminal output |
Cybersecurity Implications: Trojan Source Code Attacks and Steganography
In November 2021, Cambridge University researchers disclosed a critical vulnerability class known as Trojan Source (CVE-2021-42574). This attack vector exploits the Unicode Bidirectional (BiDi) Algorithm. Because compilers parse source tokens in linear logical order while code editors render characters according to directional overrides, attackers can construct source code that appears entirely harmless in human code review while compiling into malicious binary instructions.
Comment-Out Injection Attacks
By inserting a Right-to-Left Override (U+202E), an attacker can visually project executable exploit code inside what appears to be a multi-line code comment. The human reviewer sees only documentation, but the compiler executes the payload.
Zero-Width Fingerprinting (Steganography)
Whistleblower text and proprietary source leaks are frequently watermarked by internal systems that embed zero-width spaces (representing binary 0s) and zero-width joiners (representing binary 1s) to trace individual leakers invisibly.
Automated Sanitization in CI/CD Pipelines
To ensure non-printable Unicode characters never breach production repositories, software engineering teams should integrate pre-commit linters and automated regex sanitizers into GitHub Actions and GitLab CI stages:
# Strip all zero-width spaces, BOMs, and BiDi controls via Perl/Node regex:$ node -e 'fs.writeFileSync("file.js", fs.readFileSync("file.js", "utf8").replace(/[\u200B-\u200D\uFEFF\u202A-\u202E]/g, ""))'Programmatic Sanitization: JavaScript, Python, and SQL Snippets
Implement the following battle-tested snippets in your backend microservices to clean user input and sanitize external text streams automatically:
export function cleanText(str) {
return str
// Strip zero-width & BOM
.replace(/[\u200B-\u200D\uFEFF\u2060]/g, "")
// Normalize NBSP
.replace(/[\u00A0\u202F]/g, " ")
// Strip BiDi controls
.replace(/[\u202A-\u202E]/g, "");
}import re
def sanitize_unicode(text: str) -> str:
# Remove zero-width and BOM
pattern = r'[\u200b-\u200d\ufeff\u2060]'
cleaned = re.sub(pattern, '', text)
# Replace non-breaking spaces
return cleaned.replace('\u00a0', ' ')-- Clean column data in PostgreSQL
UPDATE user_records
SET email = REGEXP_REPLACE(
email,
'[\x{200B}\x{200C}\x{200D}\x{FEFF}]',
'',
'g'
)
WHERE email ~ '[\x{200B}\x{200C}\x{200D}\x{FEFF}]';Frequently Asked Questions (FAQ)
What are zero-width spaces and why do they break code and JSON payloads?
Zero-width spaces (such as U+200B, U+200C, and U+200D) are non-printing Unicode characters that occupy zero horizontal pixels on a screen. While visually imperceptible, they contain discrete byte sequences that cause syntax errors in JSON parsers, break string equality checks in Python and JavaScript, corrupt JWT API keys, and fail database foreign key matching.
How does this tool detect hidden Byte Order Marks (BOM) and BiDi overrides?
The tool analyzes raw text streams byte-by-byte against the complete Unicode standard database, detecting UTF-8 Byte Order Marks (U+FEFF), Bidirectional overrides (U+202E, U+202A), and C0/C1 control codes that are frequently used in Trojan Source attacks to disguise malicious executable code.
What is the difference between standard spaces and Non-Breaking Spaces (NBSP)?
A standard ASCII space is represented by character byte 0x20 (U+0020). A Non-Breaking Space (NBSP, U+00A0) is a typographical entity created by Microsoft Word, Google Docs, and HTML entities ( ) to prevent automatic line wrapping. When pasted into terminal commands or CLI tools, NBSP produces unexpected syntax errors because compilers do not treat it as valid whitespace delimiter.
Is my text secure and private when using this online zero-width cleaner?
Yes, 100% of the Unicode inspection and cleaning logic executes purely inside your local browser runtime via client-side JavaScript. No text, source code, API keys, or database dumps are ever uploaded or transmitted to an external server.
Can zero-width spaces be used for malicious steganography or digital fingerprinting?
Yes. Malicious actors and enterprise watermarking systems encode binary data (such as user IDs or secret tokens) into invisible sequences of ZWSP (binary 0) and ZWNJ (binary 1). This tool uncovers all such hidden patterns instantly and provides complete sanitization.
What are BiDi Unicode Trojan Source attacks?
Trojan Source attacks (CVE-2021-42574) exploit Bidirectional (BiDi) Unicode control characters (like U+202E Right-to-Left Override) to alter the visual display order of source code in code editors so that comments appear as executable statements or vice versa, creating stealth vulnerabilities.
Related & Complementary Utilities
Explore more privacy-first client-side web tools.
Word Combiner & Phrase Generator
Combine word lists into custom phrase matrices, domain names, and SEO keyword permutations instantly.
Small Text Generator & Unicode Font Styler
Convert text to Small Caps, Superscript, Subscript, and Unicode styles instantly.
URL & Hyperlink Text Extractor
Extract URLs and anchor text from HTML or plain text with deduplication and export capabilities.