Invisible Unicode characters and zero-width spaces
Find why identical-looking strings may fail to match or deduplicate.
Quick answer: Invisible characters are code points with no obvious visual mark, such as zero-width space U+200B and non-breaking space U+00A0. They can alter length, search, login, and duplicate detection while the text looks normal.
Copy, find and remove U+200B
Runs in your browser. Only U+200B is removed; U+200D in emoji and all other characters are preserved.
Common invisible characters
U+200B is a zero-width space; U+200D is a zero-width joiner used in many emoji sequences; U+00A0 is a non-breaking space; U+FEFF can be a byte-order mark. Do not delete all of them blindly because joiners can be required for correct display.
Warning signs
The stored length exceeds what you can see, search fails, a duplicate remains, or the cursor stops at an apparently empty position. Text copied from PDFs, websites, and chat apps commonly carries these characters.
Before
unitext[U+200B]kit
After
unitextkit
Safe handling
Inspect code points first. A non-breaking space in ordinary prose can often become a regular space; a zero-width space can be removed when it has no word-boundary purpose; a zero-width joiner should stay in emoji and scripts that need it. Review the rendered result after any change.
Non-breaking space vs regular space in copied text
A regular space is U+0020; a non-breaking space is U+00A0 and normally prevents a line break between the surrounding words. They may look identical but fail an exact string comparison. Text copied from a web page or PDF can therefore match visually while differing in stored characters.
Inspect a small sample in the Unicode normalizer. If non-breaking behavior is not required, replace U+00A0 on a copy with U+0020 before trimming and deduplicating. Keep it when a number and its unit must stay together.
Before
const text = "10\u00A0kg"; text === "10 kg"; // false
After
text.replace(/\u00A0/gu, " "); // "10 kg"
Zero-width space in copy and paste: a three-step check
First compare the code-point sequence around the failed match; then identify the exact control character; finally test one targeted change and compare again. A blank-looking cursor position is a clue, not proof that U+200B is present.
For an unwanted zero-width space, remove U+200B only as shown below. Do not use a blanket rule that deletes joiners from emoji or scripts that rely on them. If the mismatch remains, check normalization and look-alike letters separately.
U+200B vs a normal space, ZWJ and word joiner
U+200B ZERO WIDTH SPACE introduces a word or line break opportunity without the fixed width of a regular U+0020 space. U+200D ZERO WIDTH JOINER affects character joining, including emoji sequences. U+2060 WORD JOINER discourages a line break. These characters serve different purposes and should not be removed as one group.
Find and remove U+200B in JavaScript
Inspect a copy of your text in the Unicode normalizer and look for U+200B, labelled ZWSP. After confirming that those characters are unwanted, text.replace(/\u200B/gu, "") removes only U+200B and leaves joiners alone.
Neither NFC normalization nor this site’s whitespace cleaner removes U+200B. The normalizer helps you inspect the characters; it is not an automatic zero-width-space remover. Review the result before replacing the original.
Before
const text = "A\u200BB"; text.length; // 3
After
text.replace(/\u200B/gu, ""); // "AB"
How do I copy or create a U+200B character?
In JavaScript, String.fromCodePoint(0x200B) creates exactly one ZERO WIDTH SPACE. The literal escape "\u200B" in JavaScript represents the same character; typing the six visible characters backslash-u-2-0-0-B into an ordinary text field does not.
Use a code-point inspector to confirm what you copied. A visually blank selection could instead be a space, a non-breaking space, a joiner, or no character at all.
Frequently asked questions
Does NFC remove zero-width spaces?
No. Unicode normalization does not act as an invisible-character cleaner.
Can every U+200D be removed?
No. Removing it can split family, profession, and other emoji sequences or affect some writing systems.