Zero-width characters: a text transformation review

What zero-width Unicode characters change in stored text, when they help, and when they harm copy, search, editing and accessibility.

What this transformation actually changes

A zero-width character is a real Unicode code point stored in the string. It typically draws no glyph and takes no visible horizontal space, so the text can look unchanged while the underlying sequence of characters is different. This is a stored-text change, not a CSS effect, not a font, and not a mirrored or reversed appearance of letters.

The common members of this class do different jobs. A zero-width space (U+200B) can allow a line break where there is no visible space. A word joiner (U+2060) and the zero-width no-break space (U+FEFF) can inhibit a break without inserting a visible gap. A zero-width non-joiner (U+200C) can stop cursive or ligature joining between neighbouring letters. A zero-width joiner (U+200D) can request joining, including the emoji sequences that combine several emoji into one presentation. Variation selectors and a few other format characters are also zero-width; they change how adjacent characters display rather than adding a letter of their own.

CharacterTypical stored effectTypical visible effect
Zero-width space (U+200B)Inserts a break opportunityUsually none
Word joiner (U+2060)Prevents a breakUsually none
Zero-width no-break space (U+FEFF)Prevents a break; also used as a byte-order mark at the start of a fileUsually none
Zero-width non-joiner (U+200C)Blocks joining or ligaturesLetters may appear unjoined
Zero-width joiner (U+200D)Requests joining or an emoji sequenceJoined letters or a combined emoji

These characters are not combining marks. Combining marks attach to a base letter and can stack above or below it. A zero-width format character sits in the stream as its own code point and mainly affects joining, breaking or the next character’s presentation. Multi-code-point emoji are a special case: a joiner between emoji can produce one grapheme cluster that looks like a single picture, while the stored string still contains several code points. Reversing or mirroring letters is a different transformation and is not what inserting a zero-width character does.

Is this transformation suitable for the intended use?

Use it when the goal is invisible control of joining, line breaking or emoji composition, and when every later step in the workflow is known to keep format characters. The main benefit is that the reader can see ordinary words or a single emoji while the string still carries break, join or sequence information.

The decisive tradeoff is that the string is no longer the same as the visible text. Search, sort, length counts, identifiers, diffs and equality checks operate on code points, so two strings that look identical can fail to match. Hidden characters can also be stripped, normalised away or treated as suspicious by filters. That tradeoff is acceptable inside a typesetting or emoji pipeline that expects these code points. It is a poor fit for names, passwords, filenames, URLs, source code, legal copy, or any text that people will search, quote or paste into unknown tools.

Prefer ordinary plain text when a visible space, hyphen, line break or punctuation mark can do the job. A normal space is easier to see, edit and explain than a zero-width space. A hyphen or a soft hyphen is easier to reason about than an invisible break inhibitor. If the only aim is to make text look different without changing letters, this transformation does not do that: it leaves the letters looking the same and changes the hidden structure instead.

Readability and usability after copying or sharing

Copy and paste usually copies the stored code points, not only the pixels on screen. The pasted result can look identical and still contain extra characters. Editors, messaging apps and websites differ in whether they keep, normalise or strip format characters. Some destinations keep them intact. Others collapse them during paste, save or search indexing. There is no single rule that covers every app; behaviour has to be checked in the actual destination, and a successful paste in one place does not guarantee the same result elsewhere.

  • Search and find: a query typed as visible letters may miss a stored string that contains extra zero-width code points, or it may match unexpectedly if the search engine ignores format characters.
  • Editing: caret movement and backspace often step through invisible characters one by one, which feels like the cursor getting stuck. Length and substring operations count them unless the tool works in grapheme clusters.
  • Line breaking and wrapping: a zero-width space can split a word at a surprising place; a word joiner can keep a phrase from wrapping.
  • Identifiers and security: hidden characters in usernames, tokens or source can make two values look the same while remaining distinct. Many systems reject or strip format characters for that reason.
  • Bidirectional text: related marks such as left-to-right and right-to-left marks are also typically invisible and can change reading order without changing glyphs.

Assistive technology is a documented risk area with incomplete public detail for any one product. Screen readers and braille displays may skip format characters, announce them as spaces, spell out a Unicode name, or treat a joined emoji sequence as one item or as several. That behaviour depends on the engine, the voice, the browser and the host app. No single successful reading in one environment should be taken as proof that the text remains accessible everywhere. If the text must be read aloud, searched or edited by someone who cannot see the hidden code points, keep a plain-text equivalent without the extra characters.

A practical test is to compare three views of the same string: what it looks like, its code-point list, and what a find operation returns after paste into the real destination. If those three views disagree, the transformation has already cost usability. When in doubt, ship the visible letters and ordinary spaces only, and apply zero-width format characters only in the narrow layout or emoji step that requires them.