UTF-8 Byte Length Calculator

In UTF-8, ASCII characters take 1 byte, most European accented letters 2, most Asian scripts 3, and emoji 4. Byte limits in databases, APIs and protocols count bytes, not characters, so long text in other scripts can overflow sooner than expected.

Also called: String byte counter · UTF-8 byte counter

  • Last updated
  • Formula tested against reference values

Your numbers

Line breaks count as 1 byte (LF).

Result

UTF-8 bytes
—

Calculating…

Unicode code points
—
UTF-16 code units (JavaScript length)
—
UTF-16 bytes
—
ASCII characters (1 byte each)
—
Multi-byte characters
—
Against the limit
—
UTF-8 bytes (hex, first 48)
—

How to use this calculator

  1. Enter or choose text.
  2. Enter or choose byte limit to check against.
  3. The uTF-8 bytes updates as you type. Use Copy result or Share to keep it.

Method

Bytes per code point: U+0000–007F → 1; U+0080–07FF → 2; U+0800–FFFF → 3; U+10000–10FFFF → 4. Total = Σ bytes over all code points

Code point
one Unicode scalar value; an emoji with skin tone or a flag is several code points

Worked example

  1. “C”, “a”, “f” and the three spaces are ASCII: 6 × 1 = 6 bytes; “é” (U+00E9) is 2 bytes.
  2. “☕” (U+2615), “世” and “界” are 3 bytes each: 9 bytes.
  3. “🌍” (U+1F30D) is 4 bytes, so the total is 6 + 2 + 9 + 4 = 21 bytes for 11 code points.

“Café ☕ 世界 🌍” is 11 code points but 21 bytes in UTF-8.

What the result means

If you must truncate to a byte limit, cut at a character boundary so you never split a multi-byte sequence; otherwise the text becomes invalid UTF-8.

Assumptions and limits

  • Windows line endings (CR LF) are counted as a single LF, as browsers submit them.
  • What a reader sees as one character (a grapheme, such as 👍🏽 or 🇮🇳) can be several code points, so “characters” here are code points.

Questions

How many bytes is an emoji?

A single emoji code point is 4 bytes in UTF-8. Emoji with skin tones, flags or joined sequences are several code points, so often 8–25 bytes.

Why is JavaScript’s length different?

JavaScript counts UTF-16 code units, and characters beyond U+FFFF (such as most emoji) take two units each.