Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4791 pages

Free tool · Developer tools

Character encoding converter

This character encoding converter shows the bytes a text becomes in eight encodings at once, and repairs text that was read with the wrong one. The sample Café €5 😀 is 15 bytes in UTF-8, 20 in UTF-16 and 36 in UTF-32.

  • Free
  • No sign-up
  • Runs in your browser

By Maaz Zindani · Updated

What do you want to do
Hex style
Options
Bytes in each encoding

9 characters, 15 bytes in UTF-89 code points

  • UTF-8 15 bytes
  • UTF-16 20 bytes
  • UTF-32 36 bytes
  • UTF-8 15 bytes43 61 66 C3 A9 20 E2 82 AC 35 20 F0 9F 98 80
  • UTF-16 BE 20 bytes00 43 00 61 00 66 00 E9 00 20 20 AC 00 35 00 20 D8 3D DE 00
  • UTF-16 LE 20 bytes43 00 61 00 66 00 E9 00 20 00 AC 20 35 00 20 00 3D D8 00 DE
  • UTF-32 BE 36 bytes00 00 00 43 00 00 00 61 00 00 00 66 00 00 00 E9 00 00 00 20 00 00 20 AC 00 00 00 35 00 00 00 20 00 01 F6 00
  • UTF-32 LE 36 bytes43 00 00 00 61 00 00 00 66 00 00 00 E9 00 00 00 20 00 00 00 AC 20 00 00 35 00 00 00 20 00 00 00 00 F6 01 00
  • ISO-8859-1 9 bytes43 61 66 E9 20 3F 35 20 3FCannot hold € (U+20AC), 😀 (U+1F600). Written as 3F.
  • windows-1252 9 bytes43 61 66 E9 20 80 35 20 3FCannot hold 😀 (U+1F600). Written as 3F.
  • US-ASCII 9 bytes43 61 66 3F 20 3F 35 20 3FCannot hold é (U+00E9), € (U+20AC), 😀 (U+1F600). Written as 3F.

A character an encoding cannot hold is written as 3F, a question mark, which is what most converters do.

How to use the Character Encoding Converter

  1. Choose Show the bytes and type or paste text. Every encoding appears with its byte count and hex.
  2. Pick a Hex style for the way you will paste the bytes, and switch on Add a byte order mark if the file needs one.
  3. For text that looks broken, choose Fix garbled text and paste it exactly as it appears.
  4. Use Copy beside the encoding or the repaired text you want.

How do I convert text to another character encoding?

An encoding is a rule that turns each character into one or more bytes. The sample Café €5 😀 has 9 code points. In UTF-8 the plain letters take one byte each, the e with an acute accent takes two (C3 A9), the euro sign takes three (E2 82 AC) and the emoji takes four (F0 9F 98 80). The whole text reads 43 61 66 C3 A9 20 E2 82 AC 35 20 F0 9F 98 80.

The same text in UTF-16 with the low byte first reads 43 00 61 00 66 00 E9 00 20 00 AC 20 35 00 20 00 3D D8 00 DE. The emoji sits outside the first 65,536 code points, so UTF-16 writes it as a pair of two-byte units, 3D D8 00 DE. UTF-32 gives every character four bytes, so the page shows 36 bytes for 9 code points. Big and little endian differ only in the order of the bytes inside each unit.

Single byte encodings cannot hold every character. ISO-8859-1 stops at U+00FF and windows-1252 adds a few extra symbols such as the euro sign, so the euro sign is 80 in windows-1252 and cannot be written in ISO-8859-1 at all. The page writes such a character as 3F, a question mark, and lists which characters were lost. The table shows how the sample comes out.

Café €5 😀 in each encoding (first 12 bytes)
EncodingBytesHexCharacters lost
UTF-81543 61 66 C3 A9 20 E2 82 AC 35 20 F0 ...none
UTF-16 BE2000 43 00 61 00 66 00 E9 00 20 20 AC ...none
UTF-16 LE2043 00 61 00 66 00 E9 00 20 00 AC 20 ...none
UTF-32 BE3600 00 00 43 00 00 00 61 00 00 00 66 ...none
UTF-32 LE3643 00 00 00 61 00 00 00 66 00 00 00 ...none
ISO-8859-1943 61 66 E9 20 3F 35 20 3F2 written as 3F
windows-1252943 61 66 E9 20 80 35 20 3F1 written as 3F
US-ASCII943 61 66 3F 20 3F 35 20 3F3 written as 3F

Why does my text show up as café or ’?

That pattern is called mojibake. Someone saved text as UTF-8 and a program read the same bytes as windows-1252 or ISO-8859-1. The two bytes C3 A9 of é are shown as two separate characters, à and ©. Pasting café in the repair mode gives café, because the page turns each character back into its byte and reads the bytes as UTF-8.

A typographic apostrophe takes three bytes in UTF-8, so it turns into three characters. The sample It’s a café comes back as It’s a café. Here only windows-1252 works, since the bytes behind the € and ™ in ’ are printable symbols in windows-1252 and control characters in ISO-8859-1, and the page says which of the two readings matched. Text that went through the mistake twice, such as café, needs two passes, and the page finds them: café after 2 passes.

Some damage cannot be undone. When a program replaced a byte with a question mark or a plain space, the original is gone, and a garbled text with characters outside the single byte range, such as 日本, was not garbled that way. The page then explains why: "U+65E5 is not a character windows-1252 can hold, so the text was not garbled that way." Ordinary text gives a short answer too: "The text is plain ASCII, so there is nothing to repair."

Which output to pick in a character encoding converter, and what is a byte order mark?

UTF-8 keeps ASCII text at one byte per character and can write every Unicode character, which makes it the compact choice for mostly English text. The table of sizes shows the difference: the letter A takes one, two and four bytes in UTF-8, UTF-16 and UTF-32, while a CJK character takes three, two and four.

A byte order mark is a short fixed prefix at the start of a file, and each Unicode encoding has its own. The line under the table lists the prefixes the page adds when the option is on. A web browser treats the labels iso-8859-1 and latin1 as windows-1252, so text labeled as ISO-8859-1 that holds a byte such as 0x80 is shown with the euro sign.

Bytes per character
CharacterUTF-8UTF-16UTF-32ISO-8859-1windows-1252
A (letter A)12411
é (e with acute)22411
€ (euro sign)324no1
日 (CJK character)324nono
😀 (emoji)444nono

Byte order marks written by the page: UTF-8 EF BB BF; UTF-16 BE FE FF; UTF-16 LE FF FE; UTF-32 BE 00 00 FE FF; UTF-32 LE FF FE 00 00.

Use it with

  • ASCII to Hex Converter: convert ASCII text to hex codes with a byte table, control character names and five output styles. Accents and emoji become UTF-8 bytes.
  • Unicode Escape Converter: parser libraries in browser (no upload); syntax highlight; error line markers.
  • Hex to Text Converter: parser libraries in browser (no upload); syntax highlight; error line markers.

Questions

How do I convert text to UTF-8 bytes?

Type the text in Show the bytes mode and copy the UTF-8 line. The sample Café €5 😀 gives 43 61 66 C3 A9 20 E2 82 AC 35 20 F0 9F 98 80.

How do I fix text that shows as é and ’?

Switch to Fix garbled text and paste it. The page reads the characters back as bytes and decodes them as UTF-8, so café returns café.

What is the difference between ISO-8859-1 and windows-1252?

They differ only in the byte range 0x80 to 0x9F. windows-1252 puts printable symbols there, such as the euro sign at 0x80 (80), and ISO-8859-1 has control characters.

Why does a character turn into 3F?

The chosen encoding cannot hold that character, so the page writes 3F, the question mark, and lists the character. UTF-8 and the other Unicode encodings hold every character.

Why is the byte count different from the number of characters?

Most encodings use more than one byte for some characters. The emoji in the sample is 4 bytes in UTF-8, 4 in UTF-16 and 4 in UTF-32.

Does my text leave my device?

No. The bytes are worked out by code on this page with no network request.

The tool's results are computed in your browser by the code on this page, using the sources listed above; the explanations are checked against the tool's own output.