UTF-8 encode text into bytes
UTF-8 is the character encoding of the web: over 98% of websites use it, and JSON, most source code and modern operating systems default to it. The UTF-8 encode tool shows the exact bytes a string turns into, which is the key to understanding encoding bugs, byte limits and escape sequences.
How UTF-8 works
| Code points | Bytes | Example |
|---|---|---|
| U+0000 – U+007F (ASCII) | 1 | A → 41 |
| U+0080 – U+07FF | 2 | ü → C3 BC |
| U+0800 – U+FFFF | 3 | 東 → E6 9D B1 |
| U+10000 – U+10FFFF | 4 | 🚀 → F0 9F 9A 80 |
ASCII text is unchanged, which is why UTF-8 was so easy to adopt. Every byte of a multi-byte character is 0x80 or higher, so ASCII bytes such as / or " never appear by accident inside a multi-byte sequence.
Output formats
Using the input Grüße aus Köln — 東京 🚀:
| Format | Output |
|---|---|
| Escaped bytes | Gr\xC3\xBC\xC3\x9Fe aus K\xC3\xB6ln \xE2\x80\x94 \xE6\x9D\xB1\xE4\xBA\xAC \xF0\x9F\x9A\x80 |
| Hex bytes | 47 72 C3 BC C3 9F 65 20 61 75 73 20 4B C3 B6 6C 6E 20 E2 80 94 20 E6 9D B1 E4 BA AC 20 F0 9F 9A 80 |
| Decimal bytes | 71 114 195 188 195 159 101 (for “Grüße”) |
| Percent | %47%72%C3%BC%C3%9F%65 (for “Grüße”) |
| Latin-1 view | GrüÃe café (for “Grüße café”) |
The escaped format keeps ASCII readable and writes other bytes as \xHH, as Python and C would. The percent format encodes every byte, including ASCII, which is useful for checking byte-exact URL encodings.
The Latin-1 view explains mojibake
“Mojibake” is the garbage you see when UTF-8 bytes are read as Latin-1 or Windows-1252: “Grüße” becomes “Grüße” in Windows-1252. The Latin-1 view shows the Latin-1 reading, so you can confirm that a garbled string in your database or CSV is simply UTF-8 decoded with the wrong charset. The two readings differ only for bytes 0x80–0x9F: where Windows-1252 shows “Ÿ”, the Latin-1 view outputs the invisible control character U+009F. To repair it, use UTF-8 Decode.
Practical uses
- Checking byte length limits: a VARCHAR(255) in MySQL’s old utf8 charset or a 160-byte SMS field counts bytes, not characters.
- Writing byte escapes for C, Python or shell scripts (
printf '\xC3\xA9'). - Comparing with String to Hex output or a hex dump of a file.
Everything runs in your browser.
Byte patterns that are never valid UTF-8
UTF-8's structure makes corrupt data easy to spot in the hex view. Some bytes can never appear in valid UTF-8 at all:
C0andC1would only start “overlong” encodings of ASCII characters, which are forbidden.F5toFFwould encode values above U+10FFFF, the end of Unicode.- A continuation byte (
80toBF) with no lead byte before it means a character was cut in half, often by truncating a string at a byte limit.
If a file contains such bytes, it is not UTF-8. Windows-1252 text is the most common culprit: there “é” is the single byte E9 instead of C3 A9.