Format Code Now
/
Encode & decodeUTF-8 Encoder and Decoder Next: Punycode Converter ›

UTF-8 Encoder and Decoder

ED-21

Paste text to see its UTF-8 bytes as hex, decimal, \x escapes or percent codes. Paste bytes to read them as text, or list each character with its code point.

Runs in your browser. Nothing is uploaded.

Text or bytes

Result

How to use it

  1. Choose how bytes are written: hex, decimal, \x escapes or %XX.
  2. Paste text and click Text to bytes, or paste bytes in that notation and click Bytes to text.
  3. Click Show code points to list each character with its U+ number and its bytes.
  4. Copy the result, or download it as a .txt file.

How many bytes a character takes

UTF-8 writes the characters up to U+007F, which are plain ASCII, as one byte. Characters up to U+07FF take two bytes, up to U+FFFF take three, and everything above that, including emoji, takes four. So the euro sign is E2 82 AC and the grinning face emoji is F0 9F 98 80. The code points view shows the U+ number next to the bytes of every character.

Notations for the bytes

Hex is written as pairs like 48 65. Decimal is 72 101. The \x form is \x48\x65, as in many string literals, and the percent form is %48%65, as in URLs. Reading works the same way in reverse, in the notation you picked, with a clear position if a byte is missing, above 255, or not valid UTF-8, for example a lone continuation byte.

Limits to know about

Characters are counted as code points, not as the combined shapes you see, so a letter with a separate accent mark or a flag emoji shows several rows. Text with an unpaired surrogate is rejected because it has no UTF-8 form. Other encodings such as UTF-16, UTF-32 or Latin-1 are not covered, and a byte order mark is not added.

Error messages and what to do

MessageWhat it meansFix
is not a hex byteA group in hex mode is not two hex digits.Write each byte as two digits, like 48 65, or switch the notation setting.
is above 255A decimal number is too big to be one byte.Use values from 0 to 255 only.
The bytes are not valid UTF-8 textThe bytes do not form a legal UTF-8 sequence, for example a lone continuation byte or an overlong form.Check the bytes at the reported position; they may be from another encoding.

Questions people ask

How do I convert text to UTF-8 bytes?

Paste the text, pick a notation such as Hex, and click Text to bytes. Each character is written as one to four bytes. For example é becomes C3 A9. Pick decimal, \x or percent if you need another form.

How do I decode UTF-8 bytes to text?

Choose the notation that matches your bytes, paste them, and click Bytes to text. A 0x prefix on hex bytes is allowed. If the bytes are not valid UTF-8, the error names the byte that breaks the rule.

How can I see the Unicode code point of each character?

Click Show code points. You get one row per character with its U+ number, the character itself and its UTF-8 bytes. Control characters and invisible ones are labelled instead of printed, so the rows stay readable.

Why is an emoji four bytes in UTF-8?

Emoji sit above U+FFFF, and UTF-8 needs four bytes for every code point from U+10000 up. Some emoji are several code points joined together, such as a skin tone modifier added to a base emoji, so they show as more than one row.

Does it handle UTF-16 or Latin-1?

No. The tool only converts to and from UTF-8. A byte such as E9 is a complete letter in Latin-1 but is not valid UTF-8 by itself, so decoding it here gives an error.

Is my text uploaded?

No. Encoding, decoding and the code point list all use your browser, and the text you type is not sent to a server. The tool needs no account. A Share link keeps your input after the # in the address, which browsers do not send.

About this tool

Text becomes its UTF-8 bytes: one byte for ASCII, two for characters up to U+07FF, three up to U+FFFF and four above that, such as emoji. Bytes to text expects the same notation you selected and fails with a position if a byte is missing, out of range or not valid UTF-8. Show code points lists each character with its U+ number and bytes; control characters are labelled instead of printed. Characters are counted as Unicode code points, not as the combined glyphs a reader sees, so an emoji with a skin tone is two rows. Unpaired surrogates are rejected. Other encodings such as UTF-16 or Latin-1 are not covered.

Format Code Now: free, no ads, no accounts. Your input stays in your browser.