Characters vs Bytes: Why Text Length Depends on the Unit

The same text has several lengths because computers count different things. A character you see can be one or more code points, and each code point takes 1 to 4 bytes in UTF-8. So an é can be 2 or 3 bytes, and an emoji can be 4 bytes or many more. Always check which unit a limit uses.

What is the difference between a character, a code point and a byte?

People say “characters” for several different things. Four counts are in common use:

The character counter counts visible characters and shows the UTF-8 byte count next to them, so you can see two of these four at once.

How do the four counts differ for real text?

For a plain English letter they are all 1. For almost everything else they drift apart. The table was produced by the same counting code as the demo further down.

TextVisibleCode pointsUTF-16 unitsUTF-8 bytesWhat is going on
A1111A plain English letter: every count is 1.
é (U+00E9)1112The accented letter as a single code point.
e + U+03011223Looks the same as the row above, but is two code points.
€1113The euro sign.
你1113A Chinese character: 3 bytes.
😀1124An emoji above U+FFFF: 4 bytes and two UTF-16 units.
👍🏽1248An emoji plus a skin tone: one visible character, two code points.
🇲🇾1248A flag: two regional indicator letters shown as one.
👨‍👩‍👧15818A family: three people joined by two zero-width joiners.
𝐇 (U+1D407)1124A bold H from the bold text generator.
UTF-8 bytes used by each example

Each example is one visible character. A plain letter takes 1 byte, a Chinese character 3, an emoji 4 and a family emoji 18.

The last row matters if you use styled text. A bold “H” from the bold text generator, or any letter from the fancy text generator that comes from the Mathematical Alphanumeric Symbols block, takes 4 bytes where the plain letter takes 1. A bio written in fancy letters uses up a byte limit four times as fast.

How many bytes does UTF-8 use?

UTF-8 uses 1 to 4 bytes per code point, and the number depends only on the code point’s range. RFC 3629, the UTF-8 standard, sets the ranges:

Code point rangeBytesExamples
U+0000 to U+007F1English letters, digits and basic punctuation
U+0080 to U+07FF2Accented Latin letters, Greek, Cyrillic, Hebrew, Arabic
U+0800 to U+FFFF3The euro sign, Chinese, Japanese, Korean, Thai, Devanagari
U+10000 to U+10FFFF4Most emoji, mathematical bold and script letters

Because the first 128 code points are the same as ASCII and take one byte each, plain English text is the same size in characters and bytes. That is why the difference often goes unnoticed until someone types an accent or an emoji.

How many characters fit in a byte limit?

Some systems limit text in bytes, not characters. The calculator divides the limit by the bytes each kind of character needs. It assumes every character is of one kind, so a real text lands somewhere between the rows.

Byte limit calculator

If the text is allBytes eachCharacters that fit
English letters, digits, punctuation1255
Accented Latin, Greek, Cyrillic, Hebrew, Arabic2127
Most Chinese, Japanese, Korean, Thai, Devanagari385
Most emoji463

A limit of 255 bytes holds 255 English letters but only 85 Chinese characters.

How can you measure your own text?

Type or paste text into the box and see all four counts at once. Try adding an emoji, an accented letter or a word in another script.

Try it: four lengths of one text

13Visible characters
17Code points
22UTF-16 units
41UTF-8 bytes

For counts with and without spaces, words and lines, use the character counter or the word counter.

How do you check which unit a limit uses?

Before you rely on a length limit

0 of 6 done

How well do you know text lengths?

Text length quiz

1. In JavaScript, what is the length of the string containing one grinning face emoji (U+1F600)?
Show the answer

Answer: B. JavaScript counts UTF-16 code units. U+1F600 is above U+FFFF, so it needs two code units, even though it is one visible character and takes 4 bytes in UTF-8.

2. How many bytes does the Chinese character 你 (U+4F60) take in UTF-8?
Show the answer

Answer: C. U+4F60 is in the range U+0800 to U+FFFF, which UTF-8 stores in 3 bytes.

3. A field accepts 255 bytes. Roughly how many Chinese characters fit?
Show the answer

Answer: C. Each Chinese character takes 3 bytes, and 255 divided by 3 is 85.

4. The letter é can be written as an e followed by a combining accent. How many code points is that?
Show the answer

Answer: B. The e is one code point and the combining accent U+0301 is another. A counter that counts visible characters still counts it as 1.

Tools used in this guide

Frequently asked questions

Why does my text have more bytes than characters?

Only the first 128 Unicode characters, which cover English letters, digits and basic punctuation, take one byte in UTF-8. Accented letters take 2, most Chinese, Japanese and Korean characters take 3, and most emoji take 4.

Is a code point the same as a character?

Not always. A code point is a number Unicode assigns, such as U+0041 for A. What a reader sees as one character can be several code points, for example the letter e followed by a combining accent, or an emoji with a skin tone.

Why does an emoji count as 2 in JavaScript?

JavaScript string length counts UTF-16 code units. Code points above U+FFFF, which include most emoji, need two code units, so one emoji such as the grinning face has a length of 2.

Which unit should I use for a length limit?

Use the unit the system that enforces the limit uses. A form that counts what you see uses visible characters. A database column or protocol field that stores bytes uses bytes. If the rule does not say, test with an emoji and a Chinese character.

Does fancy text use more bytes?

Yes. Styled letters from the Mathematical Alphanumeric Symbols block, such as bold or script letters, are above U+FFFF and take 4 bytes each in UTF-8, against 1 byte for the plain letter.

Is my text sent anywhere when I use the demo?

No. The counting runs in your browser and your text is never uploaded.

More guides

Sources and references