When bytes matter more than characters

Many limits are written in bytes even though people think in characters. A DNS label may hold at most 63 octets, a message queue may cap a payload at a fixed number of bytes, and a database column or API field is often sized in bytes rather than in letters. A short Japanese sentence or a line with a few emoji can use two to four times as many bytes as the same number of plain English letters, so a field that looks half empty on screen can already be full. This page answers one question: how many bytes does this exact string need in UTF-8? Paste the text, read the count, and compare it with the limit in the system you are feeding. The same figure helps when you estimate file sizes for plain-text exports, check a text field before an upload fails, or explain to a colleague why a name with accents no longer fits a legacy format that assumed one byte per letter.

How UTF-8 assigns bytes

UTF-8 is defined in RFC 3629 and in the Unicode Standard, and it was designed so that ASCII text keeps its original single-byte form. Each Unicode scalar value, meaning any code point from U+0000 to U+10FFFF except the surrogate range U+D800 to U+DFFF, becomes a sequence of one to four bytes. Code points up to U+007F, which is ASCII, use one byte. Those from U+0080 to U+07FF use two, covering most Latin accents, Greek, Cyrillic, Hebrew and Arabic letters. From U+0800 to U+FFFF the encoding uses three bytes, which includes most Chinese, Japanese and Korean characters and the euro sign. Everything from U+10000 upward, including most emoji, takes four. The calculator applies exactly these ranges and adds the lengths in order.

Byte lengths for A, é and an emoji

The page starts with the three-character string Aé😀. The capital A is U+0041, an ASCII letter, so it takes 1 byte. The letter é is U+00E9 and falls in the two-byte range, so it takes 2 bytes. The grinning face emoji is U+1F600, above U+FFFF, so it takes 4 bytes. The total is 1 + 2 + 4 = 7 bytes. The example was chosen because it touches three of the four length classes in one short line. If you remove the emoji, the count drops to 3, and if you replace é with a plain e, it drops by one.

More examples from everyday text

The word naïve has five characters, but the ï takes two bytes, so the count is 6. The string €100 contains the euro sign U+20AC, which needs 3 bytes, followed by three ASCII digits, so it totals 6 bytes. The Japanese word 日本語 has three characters, each in the three-byte range, giving 9 bytes. A plain English word such as Hello needs 5. These figures show why translating a user interface can change storage needs even when the character count stays similar. A label that fits a 20-byte limit in English may not fit once it contains accented or non-Latin letters. Greek and Cyrillic words, for instance, use two bytes for nearly every letter, so a ten-letter Russian word needs about 20 bytes, while the same length in English needs 10.

Bytes, UTF-16 units and visible characters

Three different counts get confused. Bytes are what this page reports. UTF-16 code units are what JavaScript's length property returns, where characters above U+FFFF count as two units. User-perceived characters, called grapheme clusters, are what a reader sees as one symbol. For Aé😀 the three counts are 7 bytes, 4 UTF-16 units and 3 graphemes. A flag emoji such as the US flag combines two regional indicator code points of 4 bytes each, so it is 8 bytes yet looks like one symbol. A family emoji joined with zero width joiners can reach 18 bytes. None of these numbers can be derived from the others without knowing the text.

Composed and decomposed accents

The same visible word can have different byte counts depending on how it was typed. The letter é can be one code point, U+00E9, taking 2 bytes, or a plain e followed by the combining acute accent U+0301, taking 1 + 2 = 3 bytes. Both display as é, and Unicode calls them canonically equivalent. Text copied from some operating systems, file names on certain file systems and output from some text tools may use the decomposed form. This calculator counts the code points you give it and does not normalize them, so two strings that look identical can legitimately show different counts. Normalize first if your target system expects a particular form.

Invisible characters and line breaks

Some characters take bytes without showing anything. A byte order mark, U+FEFF, occupies 3 bytes at the start of some files. A zero width space, U+200B, also takes 3 bytes, and a non-breaking space, U+00A0, takes 2 where an ordinary space takes 1. A line feed is 1 byte, while a carriage return plus line feed pair is 2. Text pasted from word processors or web pages often carries a few of these, which explains a count that is higher than the visible length suggests. If the number looks wrong, check the source for hidden characters before assuming the tool is mistaken. A quick test is to delete the text, retype a short sample by hand, and compare the two counts, since the difference points to characters you could not see.

Sizing fields and truncating safely

UTF-8 never needs more than 4 bytes for one code point, so a limit of N code points can require up to 4N bytes in the worst case. A column or buffer limited to 255 bytes holds 255 ASCII letters, but only 127 two-byte letters such as é, 85 three-byte characters such as 日, and 63 four-byte emoji. When you must cut text to fit a byte limit, never cut at an arbitrary byte, because that can split a multibyte sequence and leave invalid UTF-8 at the end. Cut at a code point boundary, and preferably at a grapheme boundary so that an accent or a joined emoji is not separated from its base. Counting the whole string first, as this page does, tells you whether any cutting is needed at all.

Strict validation and limits of the count

The page rejects unpaired surrogate code units because they are not Unicode scalar values and have no valid UTF-8 form. Browser APIs such as TextEncoder typically replace them with U+FFFD, a replacement character that takes 3 bytes, so a lenient tool could report a different number for the same malformed string. Input is processed in your browser and is limited to 1 MiB of UTF-8 text, which is 1,048,576 bytes. The result is the raw encoded size. It does not include Base64 expansion, JSON escaping, compression, database overhead or protocol framing, each of which changes the final size of data in transit or storage.