Home / Guides

What Is a Zero-Width Space (U+200B)? How to Find and Remove It

Published 2026-09-30

A zero-width space is a character that takes up no space on screen, so you cannot see it, but software still counts it. That is exactly why it causes such confusing bugs. This guide explains what it is, where it comes from, how to find it, and how to remove it safely.

What is a zero-width space?

The zero-width space is the Unicode character U+200B. It has no visible shape and no width. It was designed as a hint for line breaking: it marks a spot where a line is allowed to wrap, without showing a space. That is useful for languages that are written without spaces between words, and for very long strings such as web addresses.

In HTML you can write it as ​ or ​. In most programming languages it is "\u200b".

Similar invisible characters

The zero-width space has relatives, and they behave differently:

CodeNameWhat it is for
U+200BZero-width spaceAllows a line break without showing a space
U+200CZero-width non-joinerStops two letters from joining, used in Persian and some Indic scripts
U+200DZero-width joinerJoins characters, used to build many emoji, such as family emoji
U+2060Word joinerPrevents a line break at that spot
U+FEFFByte order markMarks the encoding at the start of a file; also called zero-width no-break space

Because the last three have real jobs, removing every invisible character blindly can damage emoji or text in some languages. A good cleaner keeps them where they belong.

Where do zero-width spaces come from?

There is no single source. The usual routes are:

You usually cannot tell where a particular one came from just by looking at it. What matters is finding it and deciding whether to keep it.

What problems do they cause?

How to find zero-width spaces

In the AI Text Cleaner

Paste your text into the left box. If it contains unusual characters, a list appears under the boxes showing each code, its name and how many times it appears.

In a code editor

Visual Studio Code highlights invisible and look-alike Unicode characters by default, so a zero-width space usually shows up as a marked box. The behaviour is controlled by the editor.unicodeHighlight settings.

On the command line

Perl is installed on macOS and most Linux systems. This prints the line numbers that contain the character:

perl -CSD -ne 'print "$.: $_" if /\x{200B}/' file.txt

In a spreadsheet

To test whether a cell contains one, compare its length with the length after removing the character:

=LEN(A1) - LEN(SUBSTITUTE(A1, UNICHAR(8203), ""))

How to remove zero-width spaces

With the AI Text Cleaner

Leave the option Remove invisible characters switched on and copy the cleaned text from the right box. Nothing is uploaded; the cleaning happens in your browser.

In a spreadsheet

=SUBSTITUTE(A1, UNICHAR(8203), "")

This works in Excel and in Google Sheets.

In Python

import re
clean = re.sub(r"[\u200b\u2060\ufeff]", "", text)

Notice that this pattern leaves U+200C and U+200D alone on purpose.

On the command line

perl -CSD -pe 's/\x{200B}//g' input.txt > output.txt

In Google Docs

Open Find and replace, tick Match using regular expressions, search for \x{200B} and replace with nothing. If your version handles it differently, use a cleaner tool instead.

Should you always remove them?

No. If the text is meant for a language that uses joiners or non-joiners, or contains emoji sequences, those characters are doing real work. Remove the zero-width space and the byte order mark freely in ordinary text, but check the result if your text includes those cases.

Quick answers

Is a zero-width space the same as a normal space? No. A normal space is visible as a gap and has width. A zero-width space has neither.

Can a zero-width space make text look wrong? Sometimes it changes where a line breaks, but usually it is completely invisible, which is the reason it is hard to find.

Do zero-width spaces mean a text was written by AI? No. They come from many places and prove nothing about who wrote the text.

Try it on your own text. It lists every hidden character it finds, so you can see for yourself what was in your text. Open the AI Text Cleaner

Related guides