How to Find and Remove Invisible Characters
To find invisible characters, paste the text in a tool that counts them. To remove them, use find and replace with the Unicode code of the character, because you cannot select what you cannot see.
This guide shows the signs that a text has hidden characters, how to count them, the exact patterns that remove them, and how a code editor can show them.
Signs that a text has invisible characters
| What you notice | What it can mean |
|---|---|
| A search does not find a word that you can see | A hidden character sits inside the word |
| The character count is higher than the letters you can count | Characters without a visible shape are in the text |
| A pasted password, username or code is refused | A hidden character came along with the copy |
| A link that looks correct does not open | A hidden character is inside the address |
| The cursor needs two key presses to pass one place | A character with no width is at that place |
| Two values that look the same are treated as different | One of them has an extra character |
The cursor test is the quickest check without a tool. Move through the suspect word with the arrow key. If the cursor stops once without moving, it has stepped over a character with no width.
How to find invisible characters
The sure way is to count them. Our invisible character page has a test box that counts all characters in a pasted text and, as a separate number, the invisible ones.
- Copy the suspect text.
- Paste it in the Test it here box.
- Read the line under the box: Characters in the box and Invisible.
If Invisible is 0, the text is clean of the characters the box knows. It recognises the zero-width characters, the special spaces of Unicode, the no-break space, the Hangul fillers and the Braille blank. A normal space is not counted as invisible.
What these characters are for is covered in invisible characters explained.
How to remove invisible characters with find and replace
A hidden character is removed by searching for its Unicode code and replacing it with nothing. This needs a find and replace tool with regular expressions. The Find and Replace tool on this site has that option.
- Paste the text in the tool.
- Tick Use a regular expression.
- Type one of the patterns below in the find box.
- Leave the replace box empty, or type a normal space for the no-break space.
- Read Replacements above the result to see how many were found.
| To remove | Pattern to type | Replace with |
|---|---|---|
| Zero width space only | \u200B | Nothing |
| All zero-width characters | [\u200B-\u200D\u2060\uFEFF] | Nothing |
| No-break space | \u00A0 | A normal space |
| Hangul filler and Braille blank | [\u3164\u2800] | Nothing |
We tested the four patterns with our own tool on a text that contained six hidden characters: the second pattern found four, and the third and fourth found one each.
What the patterns mean
| Code | Character | Remove it? |
|---|---|---|
| U+200B | Zero width space | Yes, in names, links, passwords and code |
| U+200C | Zero width non-joiner | Not in Persian and some other scripts, where it is part of correct spelling |
| U+200D | Zero width joiner | Not inside emojis, where it joins the parts of a combined emoji |
| U+2060 | Word joiner | Yes, outside typesetting |
| U+FEFF | Byte order mark | Yes, when it sits in the middle of a text |
| U+00A0 | No-break space | Replace it with a normal space |
The warning in the table is important. If you remove every zero width joiner from a text with emojis, a family emoji falls apart into single people. Clean names, links and code freely, and be careful with normal writing in other scripts. The most common of these characters is explained in the guide on the zero-width space.
What a space cleaner does not remove
A tool that removes double spaces is not enough. Our Remove Extra Spaces tool cleans normal spaces, tabs and empty lines. It leaves no-break spaces and zero-width characters where they are, because they are different characters.
So the order is: first replace the special characters by their code, then clean the normal spaces.
How to see invisible characters in a code editor
Programmers have an easier way. Visual Studio Code has highlighted invisible characters since version 1.63. Its release notes say that all uncommon invisible characters in source code are highlighted by default, and so are characters that can be confused with normal ASCII letters.
| Setting in Visual Studio Code | What it controls |
|---|---|
| editor.unicodeHighlight.invisibleCharacters | Highlights invisible characters |
| editor.unicodeHighlight.ambiguousCharacters | Highlights characters that look like other characters |
| editor.unicodeHighlight.allowedCharacters | Lists characters that should not be highlighted |
For a text that is not code, paste it into an empty file in the editor. The hidden characters are highlighted, and you can delete them one by one.
How to keep invisible characters out
- Type short values by hand. A password, a username or a code of a few characters is safer typed than pasted.
- Paste as plain text. It does not remove hidden characters, but it removes formatting, which is another source of trouble.
- Check before you save. Run names, links and codes from web pages or chat apps through the test box first.
- Count twice. When a text must fit a limit, compare the character count with what you see.
Frequently asked questions
- How do I know if a text has invisible characters?
- Paste it in a tool that counts them. On our Invisible Character page, the test box shows the number of invisible characters under the box.
- How do I remove a zero-width space?
- Use find and replace with regular expressions, search for \u200B and replace it with nothing.
- Does removing extra spaces remove invisible characters?
- No. A space cleaner removes normal spaces and tabs. Zero-width characters and no-break spaces have to be removed by their code.
- Is it safe to remove all invisible characters?
- In names, links, passwords and code, yes. In normal writing, be careful: some scripts and combined emojis need the joiner characters.
- Where do invisible characters come from?
- Mostly from copy and paste. Web pages, documents and chat apps use them to control line breaks and joining, and they travel with the copied text.