How to use the UTF-8 bytes tool
- Type or paste the string into the Text box. Every character counts, including spaces and line breaks.
- Select Inspect bytes. Select Example to load a sample that mixes ASCII with two Chinese characters.
- Read three lines in the Result box: Bytes with the total, Hex with two digits per byte, and Decimal with values from 0 to 255.
- Select Copy to take the report with you.
How UTF-8 turns characters into bytes
UTF-8, specified in RFC 3629, stores each Unicode code point in one to four bytes. The first byte signals the length through its high bits, and every following byte starts with the bits 10. Because of that pattern a decoder can find character boundaries from any position, and ASCII text is unchanged.
- U+0000 to U+007F: 1 byte, 0xxxxxxx. Basic Latin letters, digits and punctuation.
- U+0080 to U+07FF: 2 bytes, the first starting with 110. Accented Latin, Greek, Cyrillic, Hebrew and Arabic.
- U+0800 to U+FFFF: 3 bytes, the first starting with 1110. Most Chinese, Japanese and Korean characters, and symbols such as the euro sign.
- U+10000 to U+10FFFF: 4 bytes, the first starting with 11110. Most emoji and rarer scripts.
UTF-8 bytes of a sample string
The sample has nine characters but 13 bytes. The seven ASCII characters take one byte each. The character 世 is U+4E16, which is 0100 1110 0001 0110 in binary. Split into 4, 6 and 6 bits and placed into the pattern 1110xxxx 10xxxxxx 10xxxxxx, it gives e4 b8 96. The second character, U+754C, becomes e7 95 8c the same way.
Hello, 世界
Bytes: 13
Hex: 48 65 6c 6c 6f 2c 20 e4 b8 96 e7 95 8c
Decimal: 72 101 108 108 111 44 32 228 184 150 231 149 140Characters, code units and bytes are different counts
A string has several lengths. The length property in JavaScript counts UTF-16 code units, so an emoji outside the Basic Multilingual Plane counts as 2. Python counts code points. UTF-8 bytes are what files, network protocols and most databases measure. The emoji U+1F600 is 1 code point, 2 UTF-16 units and 4 bytes.
What looks like one character can be several code points. The letter é can be the single code point U+00E9 (bytes c3 a9) or an e followed by the combining accent U+0301 (bytes 65 cc 81). Both render the same, yet they differ in byte length and do not compare as equal unless the text is normalized.
When the byte count matters
Byte length, not character count, decides whether a value fits in many systems. The hex line is also a quick way to find invisible characters: a no-break space shows as c2 a0, a zero-width space as e2 80 8b and a byte-order mark as ef bb bf.
- Database columns and index keys whose limits are defined in bytes.
- Cookies, where browsers cap each one at about 4096 bytes.
- Hashes and signatures, which are computed over bytes, so one invisible extra character changes the result.
- Content-Length headers, which must state the body size in bytes.
Frequently asked questions
How many bytes is one character in UTF-8?
Between one and four. ASCII characters use one byte, most accented and non-Latin alphabet letters two, most CJK characters three, and most emoji and other supplementary characters four.
Why is the byte count higher than the number of characters?
Any character outside ASCII needs more than one byte in UTF-8, and some visible characters are built from several code points. Line breaks, trailing spaces and invisible characters in the pasted text are counted as well.
Does a line break count as a byte?
Yes. Each line break in the Text box is counted as one byte, the line feed 0a. A file with Windows line endings (0d 0a) is one byte larger per line than the count shown here.
Can I convert the hex bytes back to text?
Not on this page, which only inspects. Copy the bytes from the Hex line into the Hex converter tool on this site and choose Decode to get the string back.
What is the difference between Unicode and UTF-8?
Unicode assigns a number, the code point, to every character. UTF-8 is one way to store those numbers as bytes; UTF-16 and UTF-32 are others. The code points are the same in all three, the bytes are not.