How to use this calculator
- Enter or choose text.
- Enter or choose byte limit to check against.
- 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
- “C”, “a”, “f” and the three spaces are ASCII: 6 × 1 = 6 bytes; “é” (U+00E9) is 2 bytes.
- “☕” (U+2615), “世” and “界” are 3 bytes each: 9 bytes.
- “🌍” (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.