DevTools Logo

UTF-8 Byte Counter

UTF-8 Byte Counter

Measure exact UTF-8 bytes, code points, graphemes and SMS segments for any text.

Runs in your browser
Truncate to budget in Text TruncatorCounts are exact · nothing is uploaded
Try an example

Text to measure

Measurement

0 B of 1.0 KB budget

Type text to measure it

Try héllo 👋 to see all four counts at once.

The UTF-8 Byte Counter uses the browser's TextEncoder for an exact byte count, then classifies each code point as a 1, 2, 3 or 4-byte UTF-8 character. It reports UTF-16 code units, code points and grapheme clusters separately so emoji and combining marks are never conflated. A budget meter shows remaining bytes or the exact overage, and an SMS panel applies GSM-7 (160/153 characters) or UCS-2 (70/67 UTF-16 units) segmentation rules from 3GPP TS 23.038. Unpaired surrogates are counted as U+FFFD replacements, and a note appears when combining marks mean NFC normalization would change the byte count.

Mixed script and emoji

héllo 👋 → 11 bytes, 8 UTF-16 units, 7 code points, 7 graphemes

é costs two bytes, the wave emoji four bytes and two UTF-16 units.

Composed vs decomposed

é → 2 bytes · e + ◌́ → 3 bytes

Combining marks change the byte count; the tool flags them and suggests NFC normalization.

SMS segmentation

160 ASCII chars = 1 segment · 161 = 2 (153 each) · 70 emoji = 3 UCS-2 segments

Astral emoji count as two UTF-16 units each, which switches the segment math.

Examples

héllo 👋

Input
héllo 👋
Output
11 bytes · 8 UTF-16 units · 7 code points · 7 graphemes

The canonical quadruple: é is 2 bytes, the emoji 4 bytes and 2 UTF-16 units.

Normalization changes size

Input
é vs e + ◌́
Output
2 bytes vs 3 bytes

Combining marks add a byte each; NFC would recompose the character.

SMS boundary

Input
161 ASCII chars
Output
2 segments at 153 chars each

Multipart GSM-7 messages lose 7 characters per part to the concatenation header.

About this tool

Character counts and byte counts are different numbers. An ASCII letter costs one UTF-8 byte, é costs two, a CJK ideograph three, and an astral emoji four. Databases, API payload limits and file-size budgets are measured in bytes, so counting characters alone gives the wrong answer whenever non-ASCII text is involved.

This counter uses TextEncoder for the exact UTF-8 byte count and then classifies every code point into the 1/2/3/4-byte buckets. It also reports UTF-16 code units, code points and grapheme clusters side by side, which makes emoji and combining marks legible: 👋 is one grapheme, one code point, two UTF-16 units and four bytes. A budget meter shows exact remaining bytes or overage, and the SMS panel applies the GSM-7 and UCS-2 segmentation rules from 3GPP TS 23.038.

Unpaired surrogates are counted honestly as U+FFFD (three bytes each) with a warning, and combining marks trigger a note that NFC normalization would change the count. All measurement happens locally in your browser — no text is stored or uploaded.

What this tool does not do

  • SMS segmentation follows the 3GPP baseline; individual carriers may apply different rules.
  • Grapheme counting depends on Intl.Segmenter; unsupported environments fall back to code-point counts.
  • Files over 20 MB are rejected; the tool measures pasted text in memory.

How to use this tool

  1. Paste text

    Type or paste any text into the editor. The four headline counts update live, including emoji and mixed scripts.

  2. Set a byte budget

    Enter the limit you need to stay under. The meter shows the percentage used and the exact bytes remaining or over.

  3. Inspect byte classes

    The segmented bar shows how much of the total comes from 1, 2, 3 and 4-byte characters.

  4. Read the SMS panel

    See whether the text uses GSM-7 or UCS-2, how many chargeable units it has, and how many segments it needs.

  5. Copy the summary

    Copy all counts as plain text for a ticket, spec or test fixture. Shortcut: Mod+Shift+Enter copies the summary.

Use cases

API payload limits

Check whether a user-generated field fits a 255-byte database column or a fixed request budget before sending it.

Icon and emoji planning

Understand why an emoji-heavy string costs four bytes per character and two UTF-16 units.

SMS composition

See when a message flips from GSM-7 to UCS-2 and how many segments it will consume.

Counts and classifications

FieldMeaning
UTF-8 bytesExact byte length from TextEncoder, including replacement bytes for lone surrogates
UTF-16 unitsJavaScript string length — two for astral characters such as emoji
Code pointsUnicode scalar values via Array.from(text)
GraphemesUser-perceived characters via Intl.Segmenter where available
1/2/3/4-byte classesASCII / Latin-1+Cyrillic / BMP / astral code points
GSM-7 segments160 chars single, 153 per part multipart; extension chars cost two
UCS-2 segments70 UTF-16 units single, 67 per part multipart

Carrier SMS implementations can differ; these are the 3GPP baseline rules.

Common mistakes

Mistake:Treating string.length as the byte count.

Fix:length counts UTF-16 code units, not bytes. Use the UTF-8 byte tile for budgets and limits.

Mistake:Assuming NFC and NFD text have the same size.

Fix:A decomposed é is three bytes instead of two. Watch for the combining-mark warning and normalize if your pipeline does.

Mistake:Expecting 70 emoji to fit one SMS segment.

Fix:An astral emoji is two UTF-16 units, so 70 emoji need three UCS-2 segments (67 units per part).

Frequently asked questions

Why are bytes, characters and code points different counts?

UTF-8 encodes different Unicode code points in one to four bytes: ASCII takes one, é takes two, CJK characters three and astral emoji four. Code points count Unicode scalar values, UTF-16 units count JavaScript's two-code-unit pairs for astral characters, and graphemes count what a reader perceives as one character. The tool shows all four so none of these meanings gets confused with a byte budget.

How many bytes does an emoji use?

A typical emoji such as 👋 is one code point outside the BMP, so it takes four UTF-8 bytes and two UTF-16 code units. As a grapheme it still counts as one user-perceived character. Family emoji joined with ZWJ can be several code points and many more bytes; the grapheme tile shows why they still look like one symbol.

Why does decomposed text take more bytes?

The precomposed character é (U+00E9) is two UTF-8 bytes, while e followed by a combining acute accent (U+0301) is three bytes: one for e and two for the mark. Both render the same but have different byte lengths. The tool warns when combining marks are present because NFC normalization would change the count.

How does the SMS segment estimate work?

If every character is in the GSM-7 basic or extension table, one segment holds 160 characters and multipart messages hold 153 per part (the rest is header data). Any non-GSM character switches the message to UCS-2, which holds 70 UTF-16 units per segment or 67 for multipart. That is why 70 emoji need three segments: they are 140 UTF-16 units.

What happens to unpaired surrogates?

An unpaired surrogate is not valid Unicode text. TextEncoder replaces it with U+FFFD, which is three bytes in UTF-8. The tool counts it that way and reports the number of replacements so the byte total stays honest instead of silently assuming one byte per code unit.

Is the byte count exact for every input?

Yes for text: the count comes from the platform TextEncoder specified by the Encoding Standard. The grapheme tile is the only platform-dependent value — it uses Intl.Segmenter when available and falls back to code-point counts otherwise. Nothing is uploaded or stored.

References & standards