FormatterHQ

UTF-8 Encode

Show the UTF-8 byte sequence behind any text in five formats — escaped, hex, decimal, percent-encoded or as mojibake — to debug encoding problems.

Loading tool…
Ready.

How to use the UTF-8 Encode

  1. Type or paste into the Text box, or click Sample. You can also drop a text file on either box, or load one into the UTF-8 bytes box with its Open file button.
  2. The UTF-8 bytes box updates live as you type. It works both ways — edit the UTF-8 bytes side to convert back, or click ⇄ Swap to exchange the sides.
  3. Adjust Byte format in the options bar above the editors; the result refreshes immediately.
  4. Use Copy or Download on either box to take the result, or Clear to start again.

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 pointsBytesExample
U+0000 – U+007F (ASCII)1A → 41
U+0080 – U+07FF2ü → C3 BC
U+0800 – U+FFFF3東 → E6 9D B1
U+10000 – U+10FFFF4🚀 → 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 — 東京 🚀:

FormatOutput
Escaped bytesGr\xC3\xBC\xC3\x9Fe aus K\xC3\xB6ln \xE2\x80\x94 \xE6\x9D\xB1\xE4\xBA\xAC \xF0\x9F\x9A\x80
Hex bytes47 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 bytes71 114 195 188 195 159 101 (for “Grüße”)
Percent%47%72%C3%BC%C3%9F%65 (for “Grüße”)
Latin-1 viewGrüß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:

  • C0 and C1 would only start “overlong” encodings of ASCII characters, which are forbidden.
  • F5 to FF would encode values above U+10FFFF, the end of Unicode.
  • A continuation byte (80 to BF) 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.

Frequently asked questions

How many bytes does a UTF-8 character use?
Between one and four. ASCII characters use one byte, most European and Middle Eastern letters two, most Asian scripts three, and emoji and rare characters four.
What is the difference between Unicode and UTF-8?
Unicode assigns a number (code point) to each character. UTF-8 is one way of storing those numbers as bytes; UTF-16 and UTF-32 are others.
Why does “é” show up as “é”?
The UTF-8 bytes C3 A9 were decoded as Latin-1 or Windows-1252, where C3 is à and A9 is ©. The Latin-1 view in this tool reproduces that effect.
Does UTF-8 have a byte order mark?
A UTF-8 BOM (EF BB BF) exists but is optional and usually discouraged. This tool does not add one.
Why does MySQL reject emoji?
The older MySQL character set utf8 (utf8mb3) stores at most three bytes per character, while emoji need four. Switch the column, table and connection to utf8mb4, which supports the full UTF-8 range.

Last updated October 3, 2026

Related tools