Skip to content
OneKitly

One Emoji Is One Character, Two Units, Four Bytes and Twelve

Published 11/26/2026 · 3 min read · Developer tools

Daniel Okonkwo

Daniel Okonkwo — Front-end developer and tech writer at OneKitly

Web performance · File formats

Checked against 2 sources

View profile →
In short

A grinning face is a single code point, U+1F600. JavaScript's string length reports 2, because it counts UTF-16 units and anything above U+FFFF takes a surrogate pair. Stored as UTF-8 it occupies 4 bytes. Percent-encoded for a URL it becomes %F0%9F%98%80, twelve characters. Every one of those numbers is correct for its layer, and a limit written as "20 characters" without saying which layer is a defect that will surface the first time someone types é — one character, two bytes, six percent-encoded characters.

Advertisement

Depending on which layer is counting, 😀 has length 1, 2, 4 or 12. A field limit that does not say which one is a bug waiting for a French accent.

Percent-encoding works on bytes, not on characters

That is why é becomes two triplets rather than one: the character is first turned into its UTF-8 bytes, C3 and A9, and each byte is then written as a percent sign and two hex digits. A system that encodes the same character from a Latin-1 byte produces %E9 instead, which is a different URL pointing at a different thing, and the mismatch is invisible until someone compares two links that look identical on screen. Normalising to UTF-8 before encoding is the whole fix.

Some things that look like one character are five

A family emoji is built by joining three separate people with zero-width joiners: five code points, eight UTF-16 units, eighteen UTF-8 bytes and fifty-four percent-encoded characters, all rendered as one picture. Truncating such a string by counting units splits the sequence and leaves half a family on screen. Anything that slices user text — a preview, a summary, a database column — has to cut on grapheme boundaries rather than on any of the four counts above.

The same characters, counted four ways
CharacterUTF-16 units / UTF-8 bytesPercent-encoded
a1 / 1a — 1 character
é1 / 2%C3%A9 — 6
— (em dash)1 / 3%E2%80%94 — 9
😀2 / 4%F0%9F%98%80 — 12
Web character encoding referenceEvery web form of é, à, €, the guillemets and the rest side by side: code point, HTML entity, numeric entity, UTF-8 bytes, percent-encoding for URLs and the JavaScript escape.Try the tool →
Advertisement

Frequently asked questions

Which count should a form field limit use?
Whatever the storage enforces, and it should be stated in the interface. A column declared as 100 bytes will reject a 60-character French sentence that a user counted as fitting; a column declared as 100 characters will accept it and may still break a downstream system that counts bytes. The safest arrangement is to size the storage generously, validate in the unit the user sees, and never let the two disagree silently.
Why does UTF-8 use a different number of bytes per character?
Because it was designed so that plain ASCII text stays byte-for-byte identical, which let it be adopted without rewriting the world. Characters up to U+007F take one byte, up to U+07FF two, up to U+FFFF three and the rest four. The cost is that byte length no longer tells you character count, and the benefit is that a file of English text is the same size it always was — a trade that has held for thirty years.

Articles you may find interesting

All guides →
ExplainerEncoding the Same Text Twice Turns an Ampersand Into &The first pass turns & into &. The second turns that & into & again, and the page displays the escape instead of the character.GuideBuilding a URL With Parameters That Survives a Copy-PasteThree encodings, one visible difference: %20 or +. The builder's form mode matches URLSearchParams byte for byte on seventeen values — but give it a base URL with a fragment and every parameter lands inside the hash, where no server sees it.ExplainerEscaping a String for JSON: Three Characters Are Mandatory, and One Is a TrapRFC 8259 requires exactly three things to be escaped inside a JSON string. Everything else is optional. The one that actually breaks pipelines is a lone surrogate — legal in JSON text, impossible in UTF-8, and silently replaced the moment your data is written out.GuideStripping HTML Safely: What a Tag Remover Can and Cannot DoRemoving tags and sanitising HTML are two different jobs. One real fragment run through a naive regex and through a formatting-aware stripper, with script and style contents, block breaks, comments, CDATA and entity order all shown as output.How-toHow Long Will It Take to Download a File? Time, Bits vs Bytes, and OverheadEstimate download time from file size and connection speed. Learn the size ÷ speed formula, the crucial bits-versus-bytes conversion (divide by 8), and why real downloads run slower than the math predicts.ExplainerTwelve Megapixels Prints at 34 Centimetres, and That Is the Whole Story4000 × 3000 is 12 megapixels. At 300 dots per inch that is a print 33.9 cm wide. The count answers one question about a photograph and no others.

Related tools

Sources

Spotted a mistake in this article?