How to Find Invisible Unicode Characters in Text
Find zero-width spaces, BOMs, non-breaking spaces and bidi controls hiding in text, with a free detector, terminal commands, VS Code and one-line scripts.

The short answer
When two strings look identical but refuse to match, or a form rejects an email address that is plainly correct, the cause is almost always a character you cannot see. It has a code point, it takes up a slot in the string, and it renders as nothing at all.
You find it by making the text describe itself. Three ways, from fastest to most thorough:
- Paste the text into the Invisible Character Detector. It names each hidden character by code point, counts it, and gives you a cleaned copy. It runs in your browser, so the text is processed on your device.
- On a server or in a file, use
cat -A,od -corgrep -P. They turn every byte into something printable, so the hidden ones show up as escape sequences. - In code, list every character that is not plain printable ASCII. A one-line Python or JavaScript loop prints the code point and the official Unicode name of each one.
The rest of this page shows each method on real text, explains what the usual suspects are, and lists the symptoms that should make you look for them in the first place.
What counts as an invisible character
Unicode has thousands of characters that draw nothing, or draw something you would read as an ordinary space. The ones that turn up in real data are a short list:
| Code point | Name | What it is for | How it usually arrives |
|---|---|---|---|
| U+200B | Zero-width space | A line-break hint with no width | Copied web pages, CMS editors, chat apps |
| U+200C | Zero-width non-joiner | Stops two letters joining (Persian, Indian scripts) | Copied text, keyboard input in those scripts |
| U+200D | Zero-width joiner | Joins emoji and letter forms | Emoji, Indian scripts, copied text |
| U+2060 | Word joiner | Prevents a line break, no width | Word processors, typesetting tools |
| U+FEFF | Byte order mark | Marks a file as UTF-8 or UTF-16 | The first byte of files saved by Excel and Notepad |
| U+00AD | Soft hyphen | A hyphen that only shows at a line break | Word, InDesign, PDFs |
| U+00A0 | Non-breaking space | A space that keeps two words on one line | Word, Google Docs, web pages ( ) |
| U+202F | Narrow no-break space | A thin space that never breaks | French typography, some AI chat output |
| U+202A to U+202E | Bidi embeddings and overrides | Force text direction | Copied right-to-left text, attacks on source code |
| U+2066 to U+2069 | Bidi isolates | Isolate a run of text direction | Same as above |
| U+FE00 to U+FE0F | Variation selectors | Pick a glyph style, for example emoji or text heart | Emoji pickers, phones |
| U+E0000 to U+E007F | Tag characters | Flag sequences such as the England flag | Emoji, and hidden instructions aimed at AI tools |
Two of these are not empty: U+00A0 and U+202F look exactly like a normal space. They still count, because to a computer they are a different character from U+0020, the character the space bar types, and a comparison, a split on spaces or a database lookup treats them differently.
If you want the detail on the zero-width group, including where they are legitimate and where they are abused, zero-width spaces explained covers them on their own.
Where hidden characters come from
Nobody types a zero-width space on purpose. They arrive with copy and paste:
- PDFs. Text extracted from a PDF often carries soft hyphens from the original line breaks, and non-breaking spaces from the layout.
- Word and Google Docs. Both keep non-breaking spaces typed with a shortcut or added by autocorrect, and French language settings add them before some punctuation.
- Chat apps and email. Some apps insert zero-width spaces to control where long words wrap, and forwarding preserves them.
- Web pages. A CMS that turns
into a real U+00A0, or a theme that adds U+200B to let long URLs break, hands both to anyone who copies the text. - Spreadsheets and CSV exports. Excel saves "CSV UTF-8" with a byte order mark at the start, so the first header of the file is not
name, it is U+FEFF followed byname. - AI tools. Output from chat assistants sometimes contains non-breaking or narrow no-break spaces. In 2025 users reported newer chat models emitting U+202F in ordinary answers, and OpenAI said it was not a deliberate watermark. Whatever the cause, it is real data in your text once you paste it.
The symptoms that point to them
You rarely see the character. You see what it breaks. These are the patterns worth recognising:
- A form rejects valid input. An email field fails validation because the address ends in U+200B, or a phone number has a U+00A0 between groups.
- Two identical strings compare unequal.
"admin" === "admin"returns false because one of them is six characters long. - A lookup returns nothing. A product code pasted from a PDF, a customer name copied from WhatsApp, a CSV header with a byte order mark in front of it.
- Code fails to compile or behaves oddly. A zero-width space inside an identifier gives "invalid character" errors on a line that looks perfect. A bidi control makes code run differently from how it reads, the Trojan Source problem.
- A URL breaks. A copied link opens a 404 because the browser encoded an invisible character as
%E2%80%8Bin the middle of the path. - Character counts disagree. The character counter says 31 when you can count 30. The extra one is the character you are looking for.
A quick confirmation before you go hunting: paste the two "identical" strings into the text diff tool. If it reports a difference on a line that looks the same on both sides, you have an invisible character.
A related symptom with a different cause: characters that are visible and wrong rather than invisible, such as ’ in place of an apostrophe or a stray é. Nothing is hidden in that text. The page is UTF-8 and something in the chain is reading it as Windows-1252, and weird characters on a website works through the layers in the order that finds it.
Method 1: the free Invisible Character Detector
The fastest route is the Invisible Character Detector. Paste the text, press Scan for Invisible Characters, and read the table.
Here is a real run on a five-line order note of the kind that gets copied between a chat app, a spreadsheet and an invoicing tool. Visually it is clean. The scan found eight hidden characters of six kinds:
Reading that result line by line:
- U+200B sat after "Priya", so a search for "Priya Raman" would miss this customer.
- U+200C sat before the @ in the email address, which is why the invoice tool would reject it as invalid.
- U+FEFF was at the start of the SKU line, the trace of a file saved with a byte order mark.
- U+00A0 appeared three times, in the order reference and in "6 pm", where a non-breaking space had glued the number to its unit.
- U+2060 and U+00AD were inside the SKU and the gate code.
Below the table the tool gives you a cleaned copy, with the zero-width characters deleted and the non-breaking spaces replaced by normal spaces. If you need to remove the characters rather than just find them, removing hidden characters from text covers the clean copy and its limits in detail.
Two honest notes on coverage. The detector looks for the characters people hit most often: the zero-width group, the byte order mark, non-breaking and typographic spaces, the soft hyphen and the bidi overrides U+202A to U+202E. It does not flag the bidi isolates U+2066 to U+2069, the narrow no-break space U+202F, variation selectors or tag characters. For those, use one of the scripted methods below, which list everything.
Method 2: the terminal, with cat -A, od -c and grep -P
On a Linux server, or anywhere you have GNU coreutils, three commands cover nearly every case. The sample file below has three lines: a price with a non-breaking space, a username with a zero-width space, and a CSV header with a byte order mark.
What each one tells you:
cat -A fileshows non-ASCII bytes in "M-" notation and marks every line end with$. A non-breaking space is the two bytesC2 A0, shown asM-BM-. A zero-width space isE2 80 8B, shown asM-bM-^@M-^K. You do not need to decode the notation: anything starting withM-in text you expected to be plain English is worth a look.od -c fileprints each byte, with non-ASCII bytes in octal.342 200 213is the zero-width space,357 273 277the byte order mark,302 240the non-breaking space.hexdump -C filegives the same bytes in hex, which is easier to look up.grep -nPwith a character class prints only the lines that contain the characters you name, with line numbers. That is the one to use on a 50,000 line export.
The grep that searches for the full set from the table above:
grep -nP '[\x{00A0}\x{00AD}\x{200B}-\x{200F}\x{202A}-\x{202F}\x{2060}\x{2066}-\x{2069}\x{FEFF}]' file.txtIt needs a UTF-8 locale (LC_ALL=C.UTF-8 if your shell is set to plain C). On macOS, the built-in cat has no -A flag and the built-in grep has no -P. Use LC_ALL=C cat -ve file, which prints the same M- notation, and Perl for the search, which ships with every Mac:
perl -CSD -ne 'print "$.: $_" if /[\x{00A0}\x{00AD}\x{200B}-\x{200F}\x{202A}-\x{202F}\x{2060}\x{2066}-\x{2069}\x{FEFF}]/' file.txtMethod 3: VS Code and other editors
VS Code has two settings that make hidden characters visible, and in current versions both are on by default:
editor.unicodeHighlight.invisibleCharactersdraws a box around invisible characters such as U+200B. Hover over the box and VS Code names the code point.editor.renderControlCharactersdraws control characters, including the bidi controls, as visible symbols.
If someone has switched them off, open Settings, search for "unicode highlight" and "render control characters", and turn them back on. The related setting editor.unicodeHighlight.ambiguousCharacters also flags look-alike letters, such as a Cyrillic "а" (U+0430) inside a Latin word, which is the other half of most spoofing tricks.
To search a whole project, open Find in Files, switch on regular expressions (the .* button) and search for:
[\u00A0\u00AD\u200B-\u200F\u202A-\u202E\u2060\u2066-\u2069\uFEFF]In Word and Google Docs there is no code point view, but the Show/Hide button in Word (the pilcrow) draws a non-breaking space as a small degree sign and a soft hyphen as a hooked hyphen, which is often enough to spot them.
Method 4: one-line scripts in Python and JavaScript
When you need the exact list, with positions and names, a short script beats every visual method. Both of these print every character that is not ordinary printable text, which catches the characters the detector does not cover.
Python, reading a file and printing the line number, the code point and the Unicode name:
import sys, unicodedata as u
for n, line in enumerate(open(sys.argv[1], encoding="utf-8"), 1):
for c in line.rstrip("\n"):
if not c.isprintable() or (u.category(c) in ("Cf", "Zs") and c != " "):
print(n, f"U+{ord(c):04X}", u.name(c, "?"))Run against a three-line sample, it printed:
1 U+00A0 NO-BREAK SPACE
2 U+200B ZERO WIDTH SPACE
3 U+202F NARROW NO-BREAK SPACECf is the Unicode category "format", which holds the zero-width characters, the byte order mark, the soft hyphen, the bidi controls and the tag characters. Zs is "space separator", which holds every kind of space. Anything in those two categories that is not the ordinary space is worth reporting.
JavaScript, for a browser console or Node:
const hidden = [...text]
.filter((c) => /[\p{Cf}\p{Zs}]/u.test(c) && c !== " ")
.map((c) => "U+" + c.codePointAt(0).toString(16).toUpperCase().padStart(4, "0"));
console.log(hidden); // [ 'U+00A0', 'U+200B', 'U+202F' ]
The [...text] spread matters. It walks the string by code point rather than by UTF-16 unit, so characters above U+FFFF, such as the tag characters, come out whole.
A quicker check for a single value in the console: encodeURIComponent(value). Plain ASCII comes back unchanged, and any hidden character appears as a run of %E2%80%8B-style escapes you can look up.
Which method to use when
| Situation | Best method |
|---|---|
| A single value from a form, chat or document | Invisible Character Detector |
| Two values that should match but do not | Text diff, then the detector on the odd one out |
| A large file or log on a server | grep -nP with the character class above |
| Source code in a repository | VS Code unicode highlighting, plus the regex search |
| An exact list with positions, or exotic characters | The Python or JavaScript one-liner |
What to do once you find them
Finding them is half the job. Before you delete anything, decide whether the character is noise or meaning. A zero-width space in a username is noise. A zero-width joiner inside a Hindi word or an emoji is part of the word, and removing it changes what the reader sees. A non-breaking space in "Rs 499" is doing exactly what it was put there to do.
The rule of thumb: strip from identifiers, emails, codes, URLs and keys, where only plain characters belong. Be careful in prose, names and anything multilingual. The removal guide, how to remove hidden characters from text, has the code and the checklist for that decision. For a quick manual fix, the find and replace tool accepts a regex such as [\u200B\u2060\uFEFF] with the replacement left empty, and the whitespace cleaner tidies the ordinary spaces left behind.
Stop them at the door
If the same hidden characters keep reaching your database, the durable fix is in the application rather than in a cleanup script: normalise and validate text where it enters, on every form and every import, so a pasted zero-width space never becomes a customer record. That kind of input hardening and data clean-up is part of the web application work we do. For a one-off, the detector and the commands above are all you need, and they cost nothing.
Tools mentioned in this post
- Invisible Character DetectorFind the zero-width spaces, hidden Unicode and look-alike letters in any text, see exactly where they are, and copy a clean version.
- Text Diff CheckerCompare two texts line by line: additions and deletions highlighted.
- Character CounterLive character count with platform limits: tweets, meta descriptions, SMS and more.
- Find & ReplaceReplace every occurrence in one pass: plain text or regex, case-sensitive or not.
- Whitespace CleanerStrip messy spacing: trim line edges, collapse double spaces, drop empty lines.


