GlyphSift
Style TextClean TextInspect UnicodeGuidesCompatibilityAll Tools
Open studio ↘
Home/Guides/Character Count vs. Length: Code Units, Code Points, Graphemes, and Bytes

Unicode guide

Character Count vs. Length: Code Units, Code Points, Graphemes, and Bytes

A text length is meaningful only when the unit is named. Code units, code points, graphemes, and encoded bytes describe different layers of the same string and can produce different totals.

Written & reviewed by Jack Shi · Last reviewed 2026-08-24

01

Four useful ways to count

A grapheme is a user-perceived character. It can contain one code point or a sequence of code points that Unicode text segmentation treats as one visible unit. A code-point count instead records the individual Unicode values in the string.

JavaScript's .length property counts UTF-16 code units. A code point outside the Basic Multilingual Plane is represented by a surrogate pair and therefore adds two to .length, even when it participates in a single visible grapheme.

Input👩‍💻
GlyphSift output5 UTF-16 code units · 3 code points · 1 grapheme · 11 UTF-8 bytes

The woman and laptop emoji are joined by U+200D ZERO WIDTH JOINER; GlyphSift reports each count separately.

02

One appearance, different sequences

The visible letter é may be the precomposed code point U+00E9. It may also be stored as U+0065 LATIN SMALL LETTER E followed by U+0301 COMBINING ACUTE ACCENT.

Those forms can appear alike and form one grapheme, while still having different code-point, code-unit, and byte counts. Emoji joined with U+200D provide another common case in which several code points can form one grapheme.

03

Limits depend on the counter

Text fields and protocols may count code points, graphemes, UTF-16 code units, or UTF-8 bytes. The same text can therefore fit one limit and exceed another when the counters use different units.

In UTF-8, ASCII letters use one byte, many accented Latin letters use two, most CJK characters use three, and many emoji use four. A UTF-8 byte limit should be checked as bytes rather than inferred from visible length.

Try the behavior

Related tools

inspectCharacter Counter

Count characters, words, lines, code points, and bytes with clear, distinct length models.

Open tool →
inspectGrapheme Counter

Count user-perceived characters (graphemes) and compare them to code points and UTF-16 units.

Open tool →
inspectUTF-8 Byte Counter

Compare UTF-8 bytes, code points, graphemes, and UTF-16 units without uploading the text.

Open tool →
inspectUnicode Character Inspector

Inspect code points, offsets, UTF-8 bytes, scripts, categories, and risk flags character by character.

Open tool →

Primary standards

References

  • UAX #29: Unicode Text Segmentation
  • RFC 3629: UTF-8
GlyphSiftStyle it. Clean it. Check it. Paste with confidence.
Style mapGuidesAboutAuthorContactPrivacyTermsEditorial

Independent copy-paste text tools · hello@glyphsift.com · Platform claims require evidence

Static Unicode maps target Unicode 17.0. Segmentation and normalization use the runtime's Unicode data.