What does a hex to text converter do?
Computers store text as bytes, and a byte is most often written as two hexadecimal digits: the letter H is the byte 48, and Hi is 48 69. A hex to text converter turns text into those bytes and back. You need it when you read a packet capture or a memory dump, debug a protocol, inspect a file header, check what a string really contains, or put a text constant into source code as a byte array.
The result depends on the encoding, the rule that maps characters to bytes. In UTF-8, the encoding of most of the web, é is two bytes (c3 a9) and an emoji is four. In UTF-16 every character takes two bytes (four for an emoji) and the order of the two matters: little endian writes 48 00, big endian writes 00 48. Latin-1 (ISO-8859-1) gives every character from U+0000 to U+00FF one byte, and ASCII only the first 128. This tool converts in both directions in all of these, and refuses to guess: if a character cannot be written in the chosen encoding, it tells you which one instead of writing a question mark.
It also writes the bytes the way your code needs them: spaced (48 65 6c), compact, with 0x (0x48 0x65), as \x48 escapes for strings, as a C array (0x48, 0x65) or with colons (48:65:6c), in lower or upper case, with a line break every 8, 16 or 32 bytes. Reading is just as flexible: it accepts all of those notations, mixed, with line breaks. Everything runs in your browser.
How to convert text to hex and back
- Choose the direction: "Text to hex" or "Hex to text". The page opens with an example loaded.
- Pick the encoding. Use UTF-8 unless you know the data is something else. For Windows or .NET strings in memory, UTF-16 little endian is the usual one.
- For text to hex, choose the notation, upper or lower case and, if you want, a line break every N bytes.
- Type or paste your input. The result updates as you type, with the number of bytes below it.
- Copy the result with the button. If the bytes are not valid text in that encoding, a notice says so and the bad bytes appear as
�.
Examples
The word Hi
Hi in UTF-8 is 48 69. In UTF-16 little endian it is 48 00 69 00, and in big endian 00 48 00 69.
An accented letter
é is c3 a9 in UTF-8 but a single byte, e9, in Latin-1. Decoding c3 a9 as Latin-1 gives the two characters é, the classic garbled text caused by reading UTF-8 with the wrong encoding.
A C array
Hello as a C array is 0x48, 0x65, 0x6c, 0x6c, 0x6f, ready to paste between braces. With a line break every 16 bytes a longer text stays readable.
Decoding a pasted dump
48 65 6c 6c 6f 20 77 6f 72 6c 64 gives Hello world. Pasting the same bytes with 0x prefixes or as \x48\x65... works the same way.
Common mistakes
- Reading with the wrong encoding. Strange characters such as
éor�almost always mean the bytes were decoded with another encoding than the one that wrote them. Try UTF-8, then Latin-1. - An odd number of digits. Every byte needs two digits: write
0a, nota. The tool names the group that has a missing digit. - Characters that are not hexadecimal. Only
0-9anda-fare digits. The tool shows the character and its position. - Forgetting the byte order of UTF-16. The same text gives different bytes in little and big endian. Check which one the source uses.
- Treating hex as encryption. Hex is only a way of writing bytes. To encode bytes as text for transport use Base64.
Frequently asked questions
Is hex the same as binary?
They show the same bytes in different notations. One byte is eight binary digits and two hexadecimal digits. For the binary form of text use the text to binary tool.
Why do some characters give four bytes?
In UTF-8 characters outside the Latin range take two to four bytes, and emoji take four. In UTF-16 they are a pair of 16-bit units. To see the Unicode code points themselves use text to Unicode.
Can it convert a file to hex?
This tool works on text you type or paste. To compute a fingerprint of text instead of its bytes, use the hash generator.
Does it accept dumps with offsets and ASCII columns?
No, only the bytes. Remove the address column and the text column of a hex dump first, otherwise the offsets would be read as bytes.
Is my data sent anywhere?
No. The conversion runs in your browser and nothing is stored.