Encoding Tools
String byte length calculator.
Paste a string and see its size every way a system might count it: UTF-8 bytes, UTF-16 bytes, UTF-32 bytes, JavaScript .length, Unicode code points and user-perceived characters. Add a limit to see whether it fits.
Example: naïve café € is 12 characters but 16 UTF-8 bytes (each accented letter is 2 bytes and € is 3). The family emoji is 1 character to a reader, 5 code points, 8 JavaScript units and 18 UTF-8 bytes.
Inputs
Result
Why one string has five different lengths
“Length” depends on what is being counted. In UTF-8 (RFC 3629) a code point takes 1 byte below U+0080, 2 bytes up to U+07FF, 3 bytes up to U+FFFF and 4 bytes above. In UTF-16 (RFC 2781) it takes one 16-bit unit below U+10000 and two (a surrogate pair) above. In UTF-32 every code point takes 4 bytes. JavaScript's .length, Java's String.length() and C#'s Length count UTF-16 code units, so an emoji counts as 2. A grapheme cluster, defined in UAX #29, is what a reader sees as one character, and it can be many code points (a letter plus accents, a flag, a family emoji).
| Text | Characters | Code points | UTF-16 units | UTF-8 bytes |
|---|---|---|---|---|
| A | 1 | 1 | 1 | 1 |
| é (U+00E9) | 1 | 1 | 1 | 2 |
| € (U+20AC) | 1 | 1 | 1 | 3 |
| 😀 (U+1F600) | 1 | 1 | 2 | 4 |
| 👨👩👧 | 1 | 5 | 8 | 18 |
Checking a limit. Systems state limits in different units: some in bytes, others in characters, code units or code points. Pick the unit your system documents and compare. This page counts; it does not know your platform's rules, so check its documentation for which unit applies.
Line breaks. A new line typed in the box counts as one \n character. If the receiving system stores \r\n, add one byte for each break. A lone surrogate, which cannot be written in UTF-8, is counted as 3 bytes (the replacement character U+FFFD), as TextEncoder does.
Sources: RFC 3629, UTF-8, RFC 2781, UTF-16 and UAX #29, Unicode Text Segmentation, retrieved October 2026. Related: word count checker.
Frequently asked questions
How do I get the byte length of a string?
Paste it above. The UTF-8 bytes row is the length when the string is stored or sent as UTF-8, which is what most web, API and file formats use. In JavaScript you can also get it with new TextEncoder().encode(str).length.
Why is the byte length larger than the character count?
Only ASCII characters are one byte in UTF-8. Accented letters take 2 bytes, many symbols and most CJK characters take 3, and emoji take 4.
Why is "str".length different from the number of characters?
JavaScript counts UTF-16 code units. Characters above U+FFFF, including most emoji, count as 2, and a character built from several code points (such as a family emoji) counts as more.
Which unit should I use for a database or API limit?
Whichever your system documents. Some limits are in bytes, so use UTF-8 bytes; others count characters, code units or code points. This page shows all of them so you can compare.
Is my text uploaded?
No. All counting happens in your browser.