About the Zero Width Space
What is a zero width space?
A zero width space (ZWSP) is an invisible Unicode character, U+200B, that marks where a line may break. It's also spelled zero-width space, and it takes up no room on the screen.
Unicode lists it in the General Punctuation block. Browsers wrap long words and URLs at it, and the Unicode Standard recommends it for marking word breaks in Thai, Lao, Khmer and Myanmar text, which don't put spaces between words.
It has no glyph, so text looks the same with or without one. That makes it useful for layout, and it's also why it causes bugs that are hard to see.
What should you know about U+200B?
- It isn't whitespace. It doesn't have the Unicode White_Space property, so JavaScript's
trim() and Python's strip() and split() leave it in place, and the regex \s doesn't match it.
- It takes 3 bytes in UTF-8. The bytes are E2 80 8B, so "a", U+200B and "b" make 5 bytes that still look like "ab".
- It allows a line break but never forces one. A line wraps at it only when the text doesn't fit.
- HTML has a named entity for it. Write
​, ​ or ​.
- It's been in Unicode since 1993. It was part of Unicode 1.1, with the zero width joiner and non-joiner.
How do you copy a zero width space?
- Choose how many. Leave it at 1, or enter up to 1,000.
- Click the copy button. The note under the button confirms what was copied.
- Paste it. Press Ctrl+V, or Cmd+V on a Mac. Nothing shows where you paste it, but it's there.
How do you type U+200B?
Standard keyboards have no key for it, so these methods enter it by its code, 200B, or its name.
How to type U+200B in each app and system
| Where | How to type it |
| Microsoft Word on Windows | Type 200B, then press Alt+X |
| Linux with GNOME | Press Ctrl+Shift+U, type 200b, then press Space or Enter |
| macOS | Add the Unicode Hex Input keyboard and switch to it, then hold Option and type 200B |
| HTML | Write ​ or ​ |
How do you use U+200B in HTML and CSS?
Put ​ where a long word or URL may wrap, such as after each slash. The browser breaks the line there only when it runs out of room.
The <wbr> element does the same job, and MDN notes that it behaves like U+200B. It adds no character to the text, so a reader who copies the URL gets a working link.
In CSS, content: "\200B" adds one from a stylesheet, and overflow-wrap: anywhere lets long words wrap with no extra character at all.
How does U+200B differ from other invisible characters?
Several characters and one HTML element have no width. They differ in whether they add a line break chance or block one.
U+200B compared with other invisible characters
| Character | Code point | Line break | Used for |
| Zero width space | U+200B | Adds a chance | Wrap points in long words and URLs, and word breaks in Thai and Khmer |
| Zero width non-joiner | U+200C | No effect | Keeping two letters from joining in Persian and Indic scripts |
| Zero width joiner | U+200D | Blocks one after it | Joining emoji into one, such as the family and profession emoji |
| Word joiner | U+2060 | Blocks one | Keeping two characters on the same line |
| Zero width no-break space | U+FEFF | Blocks one | The byte order mark at the start of a file |
| No-break space | U+00A0 | Blocks one | A visible space that keeps two words together |
The <wbr> element | None | Adds a chance | Wrap points in HTML that add no character |
U+FEFF used to be the only word joiner, and the Unicode Standard now strongly prefers U+2060 for joining words in new text.
Common mistakes
These mistakes with zero width characters are easy to make and hard to see.
- Two strings that look the same don't match. An invisible break character in a name or an ID makes it a different string, and
trim() doesn't remove it. Replace /\u200B/g with an empty string, or paste the text into Find and remove.
- Pasted code fails with a syntax error. Python reports "invalid non-printable character U+200B" and Node.js reports "Invalid or unexpected token" when one lands outside a string. Paste the code into Find and remove to see where it is.
- A copied URL can stop working. ZWSP characters added to a URL for wrapping get copied too, and the browser keeps them in the path as %E2%80%8B. Keep the plain URL in the link, or wrap it with
<wbr> instead.
Common Use Cases
People reach for ZWSP wherever text needs a break point or a character that shows nothing.
- Wrapping long URLs and words. Add break points to URLs, file paths and long words in narrow columns and emails.
- Thai, Lao, Khmer and Myanmar text. Mark where words end so lines wrap between words.
- Keeping an empty line. A line that holds nothing but a ZWSP isn't empty, so an app that trims lines and drops the empty ones keeps it.
- Showing @name or #tag as plain text. A zero width character after the @ or # changes how the word is written. Test it in the app first, because each app handles it differently.
- Testing your own code. Check that sign-up forms, search and comparisons handle a character nobody can see.
To check text for every kind of hidden character, not only zero width ones, use the Invisible Text Generator. For blank text that shows as a gap, use Blank Text Copy and Paste.
Frequently Asked Questions
What is the U+200B character?
U+200B, known as ZWSP, is an invisible Unicode character that allows a line break without adding space.
How do you add a zero width space in HTML?
Write ​, ​ or ​ where the line may break. The <wbr> element gives the same break without adding a character.
Is there an Alt code for U+200B?
Not a dependable one, because Windows Alt codes cover ASCII and the Windows code page. In Word, type 200B and press Alt+X instead.
How do you remove zero width spaces?
Paste the text into our Find and remove tool and copy it back without them. In JavaScript, text.replace(/\u200B/g, '') removes every U+200B.
Why does LaTeX say Unicode character U+200B is not set up?
The source has an invisible character in it, often pasted from a web page or a PDF. pdfLaTeX has no definition for it, so find it with our Find and remove tool and delete it.
How is a zero width joiner different from U+200B?
U+200B allows a break between characters, while a zero width joiner joins them. The joiner is what combines emoji such as the family emoji into one.