Zero-width space

A zero-width space is the Unicode character U+200B. It marks a point where a line may break but draws nothing, so it is invisible on screen. It is still a character in the text, which is why a word containing one no longer matches the same word typed by hand.

Some characters exist to guide how text is laid out rather than to be read. The zero-width space is one of them: it tells a line where it may break, and it is drawn as nothing at all.

Why it causes trouble

Because the character is part of the text, anything that compares text sees it. A user name copied from a web page may contain one and fail to log in. A search for a product code finds nothing because the stored copy has an invisible character in the middle. A spreadsheet lookup returns no match between two cells that look identical. In each case the screen shows the same thing and the bytes are different.

Its relatives

Several characters behave the same way. The zero-width joiner and non-joiner change how neighbouring letters connect in some scripts and in emoji. The word joiner stops a line breaking without adding space. The byte-order mark, U+FEFF, sometimes sits at the start of a pasted line from a file saved by older software. None of them is visible, and all of them change what the text is.

Finding and removing them

The reliable way to find one is to list the characters themselves rather than look at the text. A character inspector names each unusual character with its code point and the line and column where it first appears, so it can be deleted from the right place.

Frequently asked questions

How does a zero-width space get into text?

Usually by copying. Some websites, chat apps and word processors insert one to control where long words wrap, and it travels with the text when it is pasted somewhere else.

How can I find one if I cannot see it?

A character inspector lists every character that is not plain printable text, with its code point and position. A zero-width space shows up there by name even though the screen draws nothing.

Is it the same as a no-break space?

No. A no-break space, U+00A0, looks like an ordinary space and stops a line breaking at that point. A zero-width space draws nothing at all. Both can stop text matching, for the same reason.