Developer and Text Tools

Hidden Characters in Text: How to Find and Remove Them

Find zero-width spaces, bidi overrides and look-alike letters, understand why string length differs between tools, and pick the right Unicode normal form.

Saizul Amin
Saizul Amin3 Nov 2026 · 3 min read
Hidden Characters in Text: How to Find and Remove Them

When text is not what it looks like

A login fails although the password is correct. A spreadsheet lookup does not find a name that is plainly in the list. A URL copied from a chat leads to a 404. Very often the cause is a character you cannot see. Unicode contains dozens of code points that take up no space or look exactly like a normal space: the zero-width space, the zero-width joiner and non-joiner, the soft hyphen, the byte order mark and the no-break space are the usual suspects. They arrive through copy and paste from web pages, PDFs, word processors and messaging apps.

Some hidden characters are not accidents. Bidirectional controls such as RIGHT-TO-LEFT OVERRIDE change the order in which text is displayed. Attackers use them to make a file named photo_gnp.exe display as photo_exe.png, and the Trojan Source research showed the same trick hiding logic in source code reviews. Look-alike letters are a related problem: the Cyrillic а and the Latin a are different code points that most fonts draw identically, which makes convincing fake domain names.

Four ways to count a string

Developers often discover Unicode through a length bug. The answer depends on what you count. A reader sees graphemes, the units a cursor moves over. Unicode defines code points, the numbered characters. JavaScript, Java and many databases count UTF-16 code units, where every character above U+FFFF, including most emoji, takes two. Storage and network limits count UTF-8 bytes, between one and four per code point. A thumbs-up with a skin tone is one grapheme, two code points, four UTF-16 units and eight UTF-8 bytes. When a form says a name is too long or a database truncates text in the middle of an emoji, comparing these four numbers usually explains why.

Composed and decomposed forms

Accented letters can be stored two ways. é can be a single code point, or the letter e followed by a combining acute accent. They look the same but do not compare equal, so searches, deduplication and file names on different operating systems can disagree. Normalisation fixes this. NFC composes where possible and is the best default for storing and exchanging text on the web. NFD decomposes, which is useful for stripping accents. The compatibility forms NFKC and NFKD go further and fold characters such as the fi ligature, full-width letters or Roman numeral symbols into plain equivalents. That is right for search keys and usernames but can change meaning in normal prose, so use them deliberately.

Inspecting and cleaning a text

Paste the suspicious text into the Unicode Character Inspector. The findings panel tells you at once whether anything invisible, directional or mixed-script is present. In the character view, red tiles mark hidden or risky code points and blue tiles mark combining marks. Tap a tile to read its official name, category, script, block and encodings, along with escapes you can paste into code.

To clean the text, open the clean-up tab. Remove invisible characters but keep emoji joiners, so family and profession emoji stay intact. Remove bidi controls unless you work with right-to-left text that genuinely needs them. Turn unusual spaces into normal ones and pick NFC as the final form. Apply the result, check the counts again, and copy or download the clean version.

Habits that prevent the problem

Normalise user input to NFC at the boundary of your system, before storing or comparing it. Strip or reject bidi controls in identifiers, file names and code. For usernames and domains, compare a folded NFKC version and check for mixed scripts. In editors, turn on the option that shows invisible characters. And when a bug only happens with copied text, look at the code points before anything else; it saves hours of guessing.

Completely freeNo cost, no sign-up
Files stay privateEverything runs in your browser
Easy in your languageAvailable in many languages