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:
- Visible characters. What a reader sees as one character. The Unicode standard calls these grapheme clusters, or user-perceived characters.
- Code points. The number Unicode gives each character, written like U+0041 for the letter A. A visible character can be built from several code points.
- UTF-16 code units. What JavaScript counts when you ask for a string’s length. Code points above U+FFFF take two units.
- Bytes. The size of the text when it is stored or sent as UTF-8, the encoding used by most web pages and files. Each code point takes 1 to 4 bytes.
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.
| Text | Visible | Code points | UTF-16 units | UTF-8 bytes | What is going on |
|---|---|---|---|---|---|
| A | 1 | 1 | 1 | 1 | A plain English letter: every count is 1. |
| é (U+00E9) | 1 | 1 | 1 | 2 | The accented letter as a single code point. |
| e + U+0301 | 1 | 2 | 2 | 3 | Looks the same as the row above, but is two code points. |
| € | 1 | 1 | 1 | 3 | The euro sign. |
| 你 | 1 | 1 | 1 | 3 | A Chinese character: 3 bytes. |
| 😀 | 1 | 1 | 2 | 4 | An emoji above U+FFFF: 4 bytes and two UTF-16 units. |
| 👍🏽 | 1 | 2 | 4 | 8 | An emoji plus a skin tone: one visible character, two code points. |
| 🇲🇾 | 1 | 2 | 4 | 8 | A flag: two regional indicator letters shown as one. |
| 👨👩👧 | 1 | 5 | 8 | 18 | A family: three people joined by two zero-width joiners. |
| 𝐇 (U+1D407) | 1 | 1 | 2 | 4 | A bold H from the bold text generator. |
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 range | Bytes | Examples |
|---|---|---|
| U+0000 to U+007F | 1 | English letters, digits and basic punctuation |
| U+0080 to U+07FF | 2 | Accented Latin letters, Greek, Cyrillic, Hebrew, Arabic |
| U+0800 to U+FFFF | 3 | The euro sign, Chinese, Japanese, Korean, Thai, Devanagari |
| U+10000 to U+10FFFF | 4 | Most 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 all | Bytes each | Characters that fit |
|---|---|---|
| English letters, digits, punctuation | 1 | 255 |
| Accented Latin, Greek, Cyrillic, Hebrew, Arabic | 2 | 127 |
| Most Chinese, Japanese, Korean, Thai, Devanagari | 3 | 85 |
| Most emoji | 4 | 63 |
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
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
How well do you know text lengths?
Text length quiz
Tools used in this guide
- Character CounterCharacters with and without spaces, plus limit checks for X, YouTube, SMS and more.
- Word CounterLive word, character, sentence and paragraph counts, reading time and keyword density.
- Fancy Text GeneratorTurn plain text into bold, script, gothic, circled and other copy-and-paste styles.
- Bold Text GeneratorMake bold, bold italic, bold script and bold gothic text to copy and paste.
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
- RFC 3629: UTF-8, a transformation format of ISO 10646 — how many bytes UTF-8 uses for each range of code points
- Unicode Standard Annex #29: Unicode Text Segmentation — grapheme clusters, the Unicode term for user-perceived characters