Why does JavaScript count one emoji as two?
A Jolt documentation detail led to a local Node check of emoji and combining marks. Code units, code points and grapheme clusters counted the same text differently.

One smile, counted twice
For this article, a local Node check counted a single smiling face: 😀. Its string length was 2. One character had been entered, yet the number was two. The emoji had not brought a friend.
The starting point was Jolt’s official README. This Clojure implementation describes indexing strings by code point instead of UTF-16 unit, with a count of 1 for 😀 where JVM Clojure returns 2. Passing the same text across a boundary need not preserve what its length counts.
That Jolt behavior was read in the documentation, not tested here. The actual check used JavaScript. MDN documents String.length in UTF-16 code units. This emoji occupies two of those units, whereas counting code points with Array.from gives one.
Adding letters on either side produced A😀B. Its length was 4 and its code-point count was 3. Intl.Segmenter with granularity: grapheme also produced three clusters for this example. The string stayed the same; only the counting rule changed.
Imagine a field labeled “Up to 3 characters.” If its counter simply displays length, entering A😀B produces 4. The reader sees three pieces while the program counts four code units. The calculation can be correct while the instruction and counter disagree.
What “up to 3” promises
Switching to code points does not settle every meaning of “one character.” The same Node run also counted a lowercase e followed by the combining accent U+0301. That sequence had two UTF-16 units and two code points, but one grapheme cluster. On screen it can appear as a single accented e.
Intl.Segmenter’s grapheme mode is a way to work with such clusters. These few examples do not establish a perfect measure of what every reader of every language considers a character. The observed results belong to the local Node run and the stated settings.
If I built that field, I would first write down why the limit exists. Is it meant to keep a displayed name short, or to fit a storage or downstream-system constraint? Those may call for different rules. I would check the displayed counter alongside the actual rejection condition.
That matters in a fictional backend migration too. Putting the number 3 in both implementations does not necessarily allow the same text. The input contract needs a unit—code units, code points or clusters—and examples containing emoji and combining marks to check it.
Back at the field, the smiling face is still one smiling face. A small counter says how much room remains. Before changing that number, I want to ask what we agreed would occupy one space.

