Hex Translator

Convert text to hexadecimal bytes or decode hex back to text, with or without spaces and 0x prefixes. Handy for debugging, networking and encoding.

Hexadecimal, or hex, counts in sixteens rather than tens, using the digits 0 to 9 and the letters a to f. Its great virtue for computing is that one byte, a number from 0 to 255, is always exactly two hex digits, from 00 to ff. That makes hex the standard way to show raw bytes: in memory dumps, network packets, file headers, colour codes and character encodings.

Paste text and choose Encode to see its bytes in hex. “Hello” is:

48 65 6c 6c 6f

Reading and writing

On the encode side, each byte of the UTF-8 text becomes a pair of lowercase hex digits, with a space between pairs. Plain English letters give one pair each. Characters outside that give several pairs, since UTF-8 spends two to four bytes on them: “é” is c3 a9 and a thumbs up is f0 9f 91 8d.

For decoding, paste hex and choose Decode. The tool is flexible about format. It ignores spaces, line breaks and a leading 0x, and it reads the digits two at a time, so 48656c6c6f, 48 65 6c 6c 6f and 0x48 0x65 0x6c 0x6c 0x6f all give “Hello”. If there is a stray odd digit, such as an extra character at the end, it is dropped rather than guessed at, so a result that looks short is worth checking.

The result is read as UTF-8 text. Hex that came from something other than text, like a picture or a program, will decode to odd symbols; that is not a fault in the tool, since those bytes are not text.

Where hex turns up

Web developers see it in colour codes: #ff6600 is three bytes for red, green and blue. Programmers see it in error codes and memory addresses. Network engineers read packets in it. Security work involves comparing hashes, which are written in hex. URLs use it too, since percent encoding is a percent sign plus the hex of a byte, which is why a space is %20: hex 20 is 32, the code for a space. The URL encoder does that conversion.

A tip for puzzles

Hex is a regular feature of puzzle hunts and capture-the-flag games. If a string is only made of the digits 0 to 9 and letters a to f, in an even-length run, try decoding it as hex, then see if the result looks like text, Base64 or another layer. Layers are common: a message encoded in hex, then in Base64, then wrapped with a Caesar shift.

For the same bytes as ones and zeros, use the binary translator. For a more compact, mail-safe version, Base64. And to see which character each code stands for, the text to Unicode converter lists code points and bytes for every character.

Frequently asked questions

Can I paste hex with spaces or a 0x prefix?

Yes. Spaces, line breaks and 0x prefixes are ignored when decoding, so the usual ways of writing hex all work.

Why do I get symbols instead of text when decoding?

The hex probably does not represent text, or it was produced with a different encoding such as UTF-16. The tool reads the bytes as UTF-8.

How are hex and binary related?

Each hex digit stands for four bits, so a byte of eight bits is two hex digits. Hex is just a shorter way to write the same binary data.