DevToolsmith

Hex to Text and Text to Hex

Convert hex bytes to text and text to hex, using UTF-8 so accented letters and emoji work. Reads hex in any common layout, with or without spaces, 0x, \x or colons, and writes it in the layout you choose. Non-text bytes are shown as hex.

Runs 100% in your browser — nothing is uploaded

Input
Tip: drop a file here16 chars · 18 bytes · 1 line
Output
53 chars · 53 bytes · 1 line

18 bytes (UTF-8).

Characters as UTF-8 bytes

CharacterHex (UTF-8)Bytes
A 41 1
é c3 a9 2
€ e2 82 ac 3
👋 f0 9f 91 8b 4

Hex layouts

“Hello” in each output format; all of them are also accepted as input:

  • 48656c6c6f
  • 48 65 6c 6c 6f
  • 0x48, 0x65, 0x6c, 0x6c, 0x6f
  • \x48\x65\x6c\x6c\x6f
  • 48:65:6c:6c:6f

Hex in code

Python
"Hello 👋".encode().hex()            # '48656c6c6f20f09f918b'
"Hello 👋".encode().hex(" ")         # '48 65 6c 6c 6f 20 f0 9f 91 8b'
bytes.fromhex("48 65 6c 6c 6f").decode()  # 'Hello'
JavaScript
const toHex = (s) => [...new TextEncoder().encode(s)].map((b) => b.toString(16).padStart(2, '0')).join('');
const fromHex = (h) => new TextDecoder().decode(Uint8Array.from(h.match(/../g), (b) => parseInt(b, 16)));

// Node.js
Buffer.from('Hello').toString('hex');          // '48656c6c6f'
Buffer.from('48656c6c6f', 'hex').toString();   // 'Hello'
Shell
echo -n Hello | xxd -p          # 48656c6c6f
echo 48656c6c6f | xxd -r -p      # Hello
xxd file.bin | head              # hex dump with offsets and ASCII

Converting single numbers between hex, decimal and binary? Use the number base converter. Need ones and zeros? Text to binary works the same way.

Frequently asked questions

How do I convert hex to text?

Paste the hex into the input; the tool switches to “Hex → Text” when it recognises hex. Every pair of hex digits is one byte, and the bytes are read as UTF-8. Spaces, commas, colons and the 0x, \x and % prefixes are all ignored, so you can paste output from a debugger, a packet capture or C source directly.

Why does one character become several hex bytes?

Because text is encoded as UTF-8, where only ASCII characters (English letters, digits, basic punctuation) take one byte. Accented letters take two, most other scripts and symbols like € take three, and emoji take four. The table above shows a few examples.

What if the hex isn’t text?

If the bytes aren’t valid UTF-8, for example a hash, an encryption key or part of an image, the output shows them as hex bytes again and the note says it’s binary data. Use the Base64 tool to see whether it’s a known file type such as PNG or PDF.

Is hex the same as ASCII?

Hex is a way of writing bytes; ASCII is a way of mapping bytes to characters. For the 128 ASCII characters, “text to hex” gives the familiar ASCII codes (A = 41, a = 61, space = 20). UTF-8 is a superset of ASCII, so ASCII text converts the same way here.