Emoji, zero-width and hidden characters, and why counts differ
A character you can see is not always one unit of text. Emoji are built from several pieces, and some characters take up no space at all. That is why two tools can disagree about the length of the same message.
When you type the word "cat", the count is easy: three letters, three characters. Add a family emoji or paste text copied from a web page, and "length" stops being obvious. Software can legitimately report several different numbers for the same string. This guide explains the three measurements that matter and shows where invisible characters hide.
Three ways to measure one string
- UTF-16 code units. JavaScript's
string.lengthreturns this. MDN states that the property contains "the length of the string in UTF-16 code units" [1]. Characters outside the first 65,536 Unicode positions, which includes most emoji, use two units. - Unicode code points. Each assigned Unicode character is one code point, however many units it needs to be stored.
- Grapheme clusters, or "user-perceived characters". A grapheme cluster is what a reader sees as one character. The Unicode text-segmentation annex describes grapheme clusters under exactly this name [2], and browsers can count them with
Intl.Segmenterusing grapheme granularity [3].
CountText counts grapheme clusters when the browser supports it, because that matches what people mean by "character".
Worked examples
| Text | Visible characters (graphemes) | Code points | UTF-16 units (.length) | UTF-8 bytes |
|---|---|---|---|---|
| Hello | 5 | 5 | 5 | 5 |
| 😀 (grinning face) | 1 | 1 | 2 | 4 |
| 👍🏽 (thumbs up, skin tone) | 1 | 2 | 4 | 8 |
| 🇺🇸 (flag) | 1 | 2 | 4 | 8 |
| 👨👩👧👦 (family) | 1 | 7 | 11 | 25 |
| é as one code point (NFC) | 1 | 1 | 1 | 2 |
| e + combining accent (NFD) | 1 | 2 | 2 | 3 |
Look at the family emoji. It looks like one picture, and a person would call it one character. It is actually seven code points: four people joined by three invisible "zero-width joiner" characters. The Unicode emoji specification defines this directly: an emoji ZWJ sequence is an emoji sequence with at least one joiner character, with the joiner being U+200D [4]. Software that counts UTF-16 units reports 11. Software that counts grapheme clusters reports 1. X, which uses its own weighting, counts every emoji as 2 whatever its complexity [5].
The last two rows show a second source of confusion. The letter é can be stored as one code point or as an "e" followed by a combining accent mark. They look identical and are both one visible character, but they differ in code points, units and bytes. X says it normalises text to the NFC form before counting, so both ways of writing café count as 4 characters there [5].
Invisible characters
Some characters are there but not visible. They matter because they can change a count without changing what you see.
- Zero-width joiner (U+200D). Used to join emoji into a single picture, as above, and also in some scripts [4].
- Zero-width space (U+200B). Takes no space on screen. In CountText it is not treated as whitespace, so a string such as
a+ U+200B +bshows as two letters but counts as 3 characters, both with and without whitespace removed, and as 1 word. We tested this case in November 2026. - Non-breaking space (U+00A0). Looks like a normal space but stops a line from wrapping there. It is whitespace, so CountText counts it in the first total and removes it from the second, and it separates words.
- Other examples. Soft hyphens, byte-order marks, bidirectional direction marks and variation selectors are also invisible. They commonly arrive with pasted text.
CountText does not display, flag or strip invisible characters. It counts them according to the rules above. If your count looks too high, an invisible character is one of the possible reasons.
How to find hidden characters
- Compare the count with what you can see. Count the visible characters in a short snippet by hand. If the counter shows more, something invisible is present.
- Look at the two totals. If "with spaces and line breaks" minus "without whitespace" is larger than the number of spaces and line breaks you can see, you have extra whitespace characters, such as non-breaking spaces. If the numbers match but the total is still too large, suspect non-whitespace invisible characters such as zero-width ones.
- Print the code points. In a browser's developer console you can list them with a one-liner:
Values such as[...text].map(c => c.codePointAt(0).toString(16))200b,200d,feff,a0andadgive the invisible characters away. - Use a plain-text editor that shows invisible characters. Many code editors have a "render whitespace" or "show control characters" option.
- Retype a short suspicious part and compare counts. If the retyped version is shorter, you have found the culprit.
Where this matters in practice
- Posting limits. One emoji in an SMS can change the encoding of the whole message and cut the first segment from 160 to 70 characters [6]. On X, each emoji uses 2 of 280. For chat and community limits where pasted formatting also matters, see Discord, Slack and Reddit character limits.
- Application forms. Text pasted from a PDF or web page may carry invisible characters that a form's counter includes. If you are close to a limit, retype the end of a paragraph or paste via a plain-text editor.
- Usernames and identifiers. Two names that look identical can differ in invisible characters or accent composition. Compare code points when something that "looks the same" does not match.
- Databases and APIs. Limits expressed in bytes or UTF-16 units can reject text that is well under the limit in visible characters. See Characters, bytes and weights.
Browser support note
CountText relies on Intl.Segmenter for grapheme counting. If a browser does not provide it, the counter falls back to counting Unicode code points and shows a note, because in that fallback a combined emoji can count as more than 1. Current browsers provide the segmenter, but older ones may not.
Sources (checked November 2026)
- MDN Web Docs, String: length (UTF-16 code units).
- Unicode Consortium, UAX #29: Unicode Text Segmentation (grapheme clusters as user-perceived characters).
- MDN Web Docs, Intl.Segmenter.
- Unicode Consortium, UTS #51: Unicode Emoji (emoji ZWJ sequences; ZWJ is U+200D).
- X Developer Platform, Counting Characters (all emoji count as 2; NFC normalisation; example with café).
- Twilio Docs, How long can a message be? (emoji force UCS-2 and a 70-character limit).
- All counts in the table were computed by us in November 2026 in Node.js using string length, code points,
Intl.Segmenterand UTF-8 encoding.
Try it: Open the CountText counter to see characters, paragraphs and a whitespace-based word count as you type. Your text stays in your browser.