A text to hex converter shows the bytes that make up a piece of text, written in hexadecimal. Type a word or paste a paragraph, and you get the hex bytes, with the same bytes in decimal and in binary, and the count of bytes and characters. Switch the direction to turn hex bytes back into text. It works with any language and with emoji, because it uses UTF-8. It runs in your browser, so your text is not sent anywhere.
How to use the text to hex converter
- Choose text to hex or hex to text.
- Type or paste your text, or your hex bytes.
- Choose the separator and the letter case for the hex output.
- Press Convert.
What hex is
The Wikipedia article on hexadecimal explains that the digits are 0 to 9 and then A to F for the values 10 to 15. A hex digit stands for four bits, which is known as a nibble, so an 8-bit byte is two hex digits, such as 2C.[3] That is why hex is the usual way to show bytes. A byte has 256 possible values, 00 to FF, and two digits are enough to write each of them.
ASCII
The article on ASCII says that it encodes each character as a value from 0 to 127, which fits in a seven-bit integer. There are 128 code points, 95 of them printable characters and 33 control codes.[1] In hex, a space is 20 and the capital letter A is 41.[1] The digits 0 to 9 start with the bits 011.[1] So the text Hi is the bytes 48 and 69. The converter gives them as 48 69, or with another separator if you prefer, such as 0x48 0x69 or \x48\x69, which are the forms used in code.
UTF-8
Characters outside ASCII need more than one byte. The UTF-8 article describes how a code point is stored in one to four bytes. A one-byte character, from U+0000 to U+007F, has the form 0yyyzzzz; a two-byte character, up to U+07FF, has the form 110xxxyy 10yyzzzz; a three-byte character, up to U+FFFF, starts with 1110; and a four-byte character, up to U+10FFFF, starts with 11110, with every continuation byte starting 10.[2] The first 128 characters are stored as a single byte with the same value as in ASCII, so a UTF-8 file that uses only those characters is identical to an ASCII file.[2] The page works out the character 桁 (U+6841) as 11100110 10100001 10000001, which is the bytes E6 A1 81.[2]
More examples
By the same rules, the dollar sign is 24, the cent sign ¢ is C2 A2, the euro sign € is E2 82 AC, and the character 𐍈, a Gothic letter, is F0 90 8D 88. We checked these against the table of the page, which does not list them. The converter gives the same bytes, and shows 3 bytes for 1 character in the case of the euro sign. A letter with an accent, such as é, takes two bytes, C3 A9, so a word with accents has more bytes than letters. A line break is a byte too, 0A, so a pasted paragraph shows its line breaks in the hex.
Hex to text
To decode, paste the hex bytes. The converter ignores spaces, commas, colons and dashes, and the prefixes 0x, \x and %, so you can paste a dump, a URL-encoded string such as %E2%82%AC, or a string from source code. It checks that the number of digits is even, turns each pair into a byte, and decodes the bytes as UTF-8. The page notes that an overlong form, such as the bytes C0 BF for U+003F, is not allowed and must be treated as an error.[2] The converter does the same, and tells you that the bytes are not valid UTF-8 instead of showing garbled text.
A worked example
The hexadecimal article shows a hex dump that begins 57 69 6B 69 70 65 64 69 61 2C 20 74 68 65 20 66. Decoded, those bytes are the text Wikipedia, the f, and the dump goes on to spell the rest of the sentence.[3] Paste it into the hex to text mode and you see the words. The space is byte 20, the same value as in the encoded form %20 that you see in web addresses.[3]
When you need this
Developers use hex to check what is really inside a string, to debug character encoding, to write test data, and to read network traces and file headers. If a character shows up as a strange symbol, looking at its bytes tells you what encoding was used. Students use it to learn how computers store text. The binary output helps when you are studying how UTF-8 splits a character into bytes.
Escaping and encoding
The same bytes appear in other forms around the web. In a web address, each byte of a non-ASCII character is written as a percent sign and two hex digits, and the converter reads that form. In source code the bytes are often written with \x. If you need the bytes of text in another encoding, such as UTF-16, the result will differ, so say which one you use when you share bytes with others.
Common mistakes
- Counting characters as bytes. One character can take up to four bytes.
- Dropping a leading zero. Each byte is two digits, so 09 is not 9.
- Mixing up encodings. UTF-16 or Windows-1252 give other bytes for some characters.
- Pasting an odd number of digits. A digit is missing somewhere.
What next
Use this often? Add Text to Hex to your Home screen.
Frequently asked questions
What is a text to hex converter?
A tool that shows the bytes of a piece of text in hexadecimal, and decodes hex bytes back into text.
What is the hex code of the letter A?
41. The ASCII code of A is 65 in decimal, which is 41 in hex.
How many bytes is the euro sign in UTF-8?
Three: E2 82 AC. Characters outside ASCII take two to four bytes.
Can I paste hex with spaces or 0x?
Yes. Spaces, commas, 0x, \x and % are ignored when you decode.
Why can't some hex be shown as text?
The bytes may not be valid UTF-8, for example an overlong form or a stray continuation byte.
Was this tool helpful?
What went wrong?
We only receive the reason you pick, never what you typed into the tool.
Thanks for your feedback.