How to Find Invisible Characters: Unicode Code Points, UTF-8 and Graphemes
Last updated: · 9 min read
Two pieces of text that look identical on screen can be different to a computer: a zero-width space may have slipped in, an ordinary space may have been replaced by a non-breaking one, or a Latin letter may have been swapped for a Cyrillic look-alike. Differences like these break password and username comparisons, make CSV and JSON files fail to parse and cause searches to come back empty. The way to track the problem down is to split the text into individual characters and look at the Unicode code point of each. This guide explains code points, code units, bytes and grapheme clusters, how UTF-8 and UTF-16 encodings are worked out, and how invisible characters are recognised. The values in the example are real output from the Unicode Character Inspector.
Formula
Four different "lengths": code point = the number Unicode assigns to a character, U+0000 … U+10FFFF UTF-16 code unit = a 16-bit unit (what "text".length counts in JavaScript) UTF-8 byte = the space taken up in files and on the network grapheme cluster = what a user perceives as one character (UAX #29) UTF-8 (RFC 3629): U+0000–U+007F → 1 byte 0xxxxxxx U+0080–U+07FF → 2 bytes 110xxxxx 10xxxxxx U+0800–U+FFFF → 3 bytes 1110xxxx 10xxxxxx 10xxxxxx U+10000–U+10FFFF → 4 bytes 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx UTF-16: U+0000–U+FFFF → 1 unit (the code point itself) U+10000 and above → 2 units: c' = c − 0x10000; high = 0xD800 + (c' >> 10), low = 0xDC00 + (c' & 0x3FF)
Unicode gives every character a code point, and the encoding forms turn that number into bytes. In UTF-8 the bits of the code point are spread over one to four bytes depending on its size; the leading bits of the first byte state the length of the sequence and the 10 at the start of each following byte marks it as a continuation. In UTF-16, characters up to U+FFFF take one unit and larger ones take two, known as a surrogate pair. The tool splits the text into code points and shows, for each one, both encodings, the hexadecimal HTML entity (&#x…;), the JavaScript escape (\u{…}), the general category and the script. Category and script come from the browser's Unicode data, and the grapheme count from the browser's text segmenter (Intl.Segmenter). Certain characters that are invisible or can mislead are flagged with ⚠ and summarised at the top.
What the inputs mean
- Text
- The text to inspect. Nothing is trimmed: leading and trailing spaces, tabs and line breaks are listed too, because that is often exactly where the problem is. A space is shown as ␣, control characters as symbols such as ␉, and other invisible characters as □. The first 2,000 code points are listed; for longer texts the counts still cover the whole input.
Worked example: A five-character text that is six units and thirteen bytes long
- The input is the tool's default text: A, é, €, 😀 and, at the end, a zero-width space (U+200B) that the eye cannot see. Four characters are visible on screen.
- The summary lines read: UTF-16 code units: 6, Code points: 5, Grapheme clusters (visible characters): 5, UTF-8 bytes: 13. One text, four different numbers; which one is right depends on what you are measuring.
- Directly below comes the warning: ⚠ Invisible or potentially misleading characters: U+200B ×1
- The listing, line by line: A | U+0041 | UTF-8: 41 | UTF-16: 0041 | A | \u{41} | letter (L) | Script=Latin
- The letter é is one code point but two bytes in UTF-8: é | U+00E9 | UTF-8: C3 A9 | UTF-16: 00E9 | é | \u{E9} | letter (L) | Script=Latin. U+00E9 is 000 1110 1001 in binary; placed into the pattern 110xxxxx 10xxxxxx it becomes 11000011 10101001, that is C3 A9.
- The euro sign takes three bytes: € | U+20AC | UTF-8: E2 82 AC | UTF-16: 20AC | € | \u{20AC} | symbol (S) | Script=Common
- The emoji lies above U+FFFF, so it takes four bytes in UTF-8 and two units in UTF-16: 😀 | U+1F600 | UTF-8: F0 9F 98 80 | UTF-16: D83D DE00 | 😀 | \u{1F600} | symbol (S) | Script=Common. 0x1F600 − 0x10000 = 0xF600; the high unit is 0xD800 + (0xF600 >> 10) = D83D and the low unit 0xDC00 + (0xF600 & 0x3FF) = DE00.
- The invisible character shows up on a line of its own: □ | U+200B | UTF-8: E2 80 8B | UTF-16: 200B | ​ | \u{200B} | format (Cf) | Script=Common | ⚠ zero-width space (ZWSP)
- Same appearance, different code points: write é as an e followed by a combining acute accent (U+0301) and the tool shows Code points: 2 and Grapheme clusters (visible characters): 1. What looks like one character is two code points; the second line reads: ◌́ | U+0301 | UTF-8: CC 81 | UTF-16: 0301 | ́ | \u{301} | combining mark (M) | Script=Inherited
- A joined emoji: for the family emoji made of a man, a woman and a girl the tool shows Code points: 5, Grapheme clusters (visible characters): 1 and UTF-8 bytes: 18. Three emoji and the two zero-width joiners (U+200D) between them form a single grapheme; the tool lists those joiners in the warning as well, although here they are doing a legitimate job.
Result: A, é, €, 😀 and U+200B → UTF-16 code units: 6; Code points: 5; Grapheme clusters (visible characters): 5; UTF-8 bytes: 13
🔬 Unicode Character Inspector
Free, no sign-up; your data stays in your browser.
Open the calculator →How to read the result
A warning sign does not mean an error; it shows where to look. The zero-width joiner belongs in emoji sequences, the zero-width non-joiner in the spelling of languages such as Persian, the non-breaking space in French punctuation and number formats, and the soft hyphen in hyphenation hints. If the same characters turn up in a username, an API key, a file name or source code, they most likely got there by accident or are meant to deceive. Bidirectional controls can change the visible order of text, so they deserve particular care in source code and file names. For look-alike letters, the script column is the clue: a single Script=Cyrillic line among Latin letters is usually the culprit. The tool does not show official Unicode character names and does not perform confusable mapping; it gives the category at its top level (letter, number, punctuation and so on) and recognises the script among 43 common ones, printing Unknown for the rest. Because the grapheme count depends on the Unicode version built into the browser, it can differ between browsers for very recent emoji sequences.
Common mistakes
- Mixing up characters, bytes and code units. A database column limit may count bytes, JavaScript's length property counts UTF-16 units, and users see graphemes; decide which one you mean before setting a limit.
- Cutting text by UTF-16 units. A string cut through the middle of an emoji leaves a lone surrogate, which cannot be encoded as UTF-8 and shows up as a broken character.
- Assuming trim() removes every invisible character. In JavaScript, trim() removes the non-breaking space and the BOM but not the zero-width space (U+200B), the zero-width joiner or the soft hyphen; those have to be cleaned up separately.
- Comparing look-alike strings without normalising them. The single code point é (U+00E9) and e + U+0301 are not equal; bring both sides to the same Unicode normalisation form (NFC, for instance) before comparing.
- Overlooking a BOM at the start of a file. In a CSV or JSON file that begins with U+FEFF, the first column name or the first key carries an invisible character and fails to match.
- Trusting text copied from Word, a PDF or a web page. Non-breaking spaces, smart quotes and long dashes arrive this way; inspect the text before pasting it into a command line or a configuration file.
- Trying to tell look-alike letters apart by eye. Latin a (U+0061) and Cyrillic а (U+0430) are identical in most fonts; only the code point shows the difference.
Frequently asked questions
How do I find invisible characters in a text?
Paste the suspect text into the tool. The warning line at the top counts characters that are invisible or may mislead, with their code points and how often they occur; in the list below, each appears on its own line as □ with a ⚠ explanation. If there is no warning, compare the number of code points with the number of characters you can see, and check the Script column for a writing system you did not expect.
What is a zero-width space?
It is the code point U+200B: a format character with no width that marks a place where a line may break. It is used in scripts that do not put spaces between words, such as Thai, and for breaking long URLs. Because it is invisible it travels unnoticed with copy and paste; it makes the text different and takes three bytes in UTF-8 (E2 80 8B).
Is a code point the same as a character?
Not always. A code point is a single number in Unicode, whereas what a user sees as a character is a grapheme cluster, which can consist of several code points. An accented letter can be two, a flag is two, and a family emoji can be five or more.
Why does one emoji count as 2 characters?
Languages such as JavaScript, Java and C# measure string length in UTF-16 code units. Code points above U+FFFF, which includes most emoji, are written with two units. That is why length returns 2 for 😀; in UTF-8 it is four bytes.
What is the difference between UTF-8 and UTF-16?
Both encode every Unicode code point; they differ in their units. UTF-8 uses one to four bytes, is compatible with ASCII and dominates in files and network protocols. UTF-16 uses two or four bytes and is the internal string representation of JavaScript, Java and Windows. The tool shows both side by side for every character.
How can I tell a non-breaking space from a normal space?
Not by looking at it. A normal space is U+0020 and one byte in UTF-8 (20); a non-breaking space is U+00A0 and two bytes (C2 A0). The tool shows the first as ␣ and the second as □ with a warning. They are different characters, so they do not match each other in searches or when splitting text.
Is my text sent anywhere?
No. The inspection is done by JavaScript on the page, in your browser.
The result is not exact or binding and is for information only; it is not an official document and cannot be used in official procedures. Confirm it with the competent authority or a professional before acting; no liability is accepted for losses arising from its use.
Sources
- The Unicode Standard, Version 18.0 — Chapter 2: General Structure (code points, encoding forms, combining characters)
- The Unicode Standard, Version 18.0 — Chapter 23: Special Areas and Format Characters (zero-width characters, BOM, bidirectional controls)
- Unicode Standard Annex #29 — Unicode Text Segmentation (grapheme clusters)
- Unicode Standard Annex #44 — Unicode Character Database (General_Category values)
- Unicode Standard Annex #24 — Unicode Script Property
- Unicode Technical Standard #39 — Unicode Security Mechanisms (confusable characters)
- RFC 3629 — UTF-8, a transformation format of ISO 10646