Text to Hex Converter

Convert a string into hexadecimal bytes such as 48 65 6C 6C 6F, or decode hex back into text. Useful for checking character encodings and debugging. Everything runs in your browser.

Text is stored as bytes

Computers store text as numbers. A character encoding such as UTF-8 defines which bytes represent each character, and hexadecimal is the usual way to look at those bytes: each byte is written as two hex digits from 00 to FF. ASCII characters take one byte in UTF-8, while other characters take two to four.

CharacterCode pointUTF-8 bytes (hex)
AU+004141
éU+00E9C3 A9
€U+20ACE2 82 AC
😀U+1F600F0 9F 98 80

So Hello is 48 65 6C 6C 6F and café is 63 61 66 C3 A9 — five bytes for four characters. When text shows up garbled (“mojibake”, such as é instead of é), looking at the raw hex is the fastest way to find out which encoding was actually used.

The Shift_JIS and EUC-JP options are legacy Japanese encodings. The same character produces different bytes in each: あ is E3 81 82 in UTF-8, 82 A0 in Shift_JIS and A4 A2 in EUC-JP.

Flexible hex input

When decoding, spaces, commas, colons, hyphens, line breaks and the prefixes 0x, \x and % are stripped automatically. You can paste the hex part of a hex editor, Wireshark or xxd dump, a C byte array, or a percent-encoded string as-is.

Hex in code

LanguageText → HexHex → Text
Pythons.encode().hex()bytes.fromhex(h).decode()
Node.jsBuffer.from(s).toString('hex')Buffer.from(h, 'hex').toString()
PHPbin2hex($s)hex2bin($h)
Java 17+HexFormat.of().formatHex(s.getBytes(UTF_8))new String(HexFormat.of().parseHex(h), UTF_8)
Gohex.EncodeToString([]byte(s))hex.DecodeString(h)
Shellprintf '%s' 'Hello' | xxd -pecho 48656c6c6f | xxd -r -p

Frequently asked questions

Why do I get “These bytes are not valid UTF-8”?

The hex does not form valid text in the selected charset. Try another charset, or check whether the data is binary (an image, compressed data) rather than text.

What does EF BB BF at the start mean?

It is the UTF-8 byte order mark (BOM), an optional 3-byte marker some editors add to the start of a file. Converting text to hex is an easy way to see whether a BOM is present — it can break CSV imports, shell scripts and JSON parsers.

What hex input formats are accepted?

Spaces, commas, colons, hyphens, line breaks and the prefixes 0x, \x and % are removed automatically, so you can paste hex dumps, C arrays or percent-encoded strings directly.