UTF-8 Converter
ED-64Convert text to its UTF-8 bytes and back, and see the same text as UTF-16 code units or UTF-32 values. Code points are listed too.
Runs in your browser. Nothing is uploaded.
Text or code units
Result
How to use it
- Paste your text, or the bytes or code units you want to decode, into the input box.
- For UTF-8, choose how bytes are written: hex, decimal, \x escapes or %XX.
- Click Text to UTF-8, Text to UTF-16 or Text to UTF-32. To decode, click UTF-8 to text or UTF-16 to text.
- Click Show code points for a table of each character, its U+ number and its UTF-8 bytes.
UTF-8 bytes
UTF-8 writes each character as one to four bytes: one for ASCII, two up to U+07FF, three up to U+FFFF and four above that, which covers emoji. The tool shows those bytes in the notation you choose. Decoding expects the same notation and stops with a position if a byte is missing, out of range or not valid UTF-8, for example a lone continuation byte.
UTF-16 and UTF-32
UTF-16 uses 16-bit code units. Characters up to U+FFFF are one unit, and others are a surrogate pair of two units, so an emoji such as U+1F600 shows as D83D DE00. UTF-32 uses one value per code point, padded to 8 hex digits. UTF-16 to text accepts units separated by spaces or commas, with 0x, \u or U+ prefixes allowed, and rejects an unpaired surrogate.
Values, not files
This page shows and reads values. It does not add a byte order mark, set an endianness or save a file in an encoding. It works with Unicode code points, not with the combined characters a reader sees, so an e followed by a combining accent counts as two. A lone surrogate in the input cannot be encoded as UTF-8 and is reported.
Error messages and what to do
| Message | What it means | Fix |
|---|---|---|
is not a UTF-16 code unit | A token is not 1 to 4 hex digits. | Use values such as 0048 or D83D. |
unpaired surrogate | A high surrogate (D800 to DBFF) is not followed by a low one (DC00 to DFFF), or the reverse. | Add the missing half or remove the unit. |
No UTF-16 code units found | The input is empty. | Paste hex such as 0048 0069 D83D DE00. |
Questions people ask
How do I convert text to UTF-8 bytes?
Paste the text and click Text to UTF-8. Each character is shown as its UTF-8 bytes, in hex by default. Choose decimal, \x escapes or %XX under UTF-8 bytes written as if you need another notation.
How do I convert UTF-8 to UTF-16?
Paste the text itself, not its bytes, and click Text to UTF-16. You get the 16-bit code units in hex. To start from UTF-8 bytes, decode them to text first with UTF-8 to text, then convert.
Why is an emoji two UTF-16 units?
UTF-16 stores characters above U+FFFF as a surrogate pair: a high unit from D800 to DBFF and a low unit from DC00 to DFFF. The emoji U+1F600 becomes D83D DE00. UTF-8 stores it as four bytes, and UTF-32 as one value.
How many bytes does a character take in UTF-8?
One byte up to U+007F, two up to U+07FF, three up to U+FFFF and four from U+10000. Letters like é take two, euro sign three, and most emoji four. Show code points lists the bytes for each character.
Does it add a byte order mark?
No. The values are shown as they are, with no BOM and no byte order choice. UTF-16 units are printed as numbers, not as a file in an encoding, so there is nothing to order.
What does an invalid UTF-8 error mean?
The bytes you pasted are not a valid UTF-8 sequence, for example a continuation byte without a start byte, an overlong form or a value above U+10FFFF. The message gives the position so you can find the bad byte.
About this tool
Text to UTF-8 writes the bytes of each character: one for ASCII, two up to U+07FF, three up to U+FFFF and four above that. UTF-16 output is the sequence of 16-bit code units, so an emoji is a surrogate pair of two units, and UTF-32 output is one 8-digit value per code point. UTF-16 to text accepts units with spaces or commas, with or without 0x, \u or U+ in front, and rejects an unpaired surrogate. These show values, not files: no byte order mark is added and nothing is saved in an encoding. A lone surrogate in the input cannot be encoded and is an error.