Skip to content
nearnull

Hex Converter

Convert text to hexadecimal and hex back to text, UTF-8 safe. Runs entirely in your browser. Nothing is sent to any server.

Result
Your converted output appears here

What is hex encoding?

Hexadecimal encoding writes each byte as two characters from 0-9 and a-f, so any data can be represented in plain, printable text. This tool encodes in both directions: it turns text into the hex of its UTF-8 bytes, and turns hex back into readable text. Because it works on bytes rather than characters, a single accented letter or emoji becomes several hex pairs: 'é' is c3 a9 and '🦩' is f0 9f a6 a9. Everything runs locally in your browser, so nothing you paste is ever transmitted.

Examples

The same conversion in the languages you're most likely to reach for:

JavaScript
const hex = [...new TextEncoder().encode(str)]
  .map((b) => b.toString(16).padStart(2, "0"))
  .join("");
Python
str.encode("utf-8").hex()
bytes.fromhex(hex).decode("utf-8")
Java
HexFormat.of().formatHex(str.getBytes(StandardCharsets.UTF_8))
Go
import "encoding/hex"

hex.EncodeToString([]byte(s))
PHP
bin2hex($str);
hex2bin($hex);
Shell
printf "%s" "$str" | xxd -p
echo "$hex" | xxd -r -p

Use Cases

Reading a hex dump

Paste bytes copied out of xxd, hexdump, Wireshark or a debugger and get the readable string back, without wiring up a script just to decode one line.

Checking what a string really contains

Invisible characters are the usual suspect when two strings look identical but don't compare equal. Encoding to hex exposes them: a non-breaking space (c2 a0), a zero-width space (e2 80 8b) or a trailing carriage return (0d) all become visible.

Building fixture data for tests

Produce the exact byte sequence a parser, protocol or binary format test expects, with the separator style that matches the language you're writing the fixture in.

Verifying an encoding assumption

If text arrives mangled from a database or an API, the hex tells you whether you're looking at UTF-8 read as Latin-1, double-encoded UTF-8, or genuinely corrupt bytes.

Frequently Asked Questions

Which text encoding does this tool use?
UTF-8, in both directions. Text is encoded to its UTF-8 bytes, and hex is decoded as UTF-8. UTF-8 is the default for the web, JSON, and virtually every modern API, so it's what you want unless you know you're working with a legacy encoding.
Why do I get an error on hex that looks perfectly valid?
There are two different errors. 'Not valid hex' means the input has characters outside 0-9 and a-f, or an odd number of digits (each byte needs exactly two). 'Not valid UTF-8' means the hex parsed fine but the resulting bytes don't spell out text: that happens with genuinely binary data, like a compressed file or an image header, or with text in another encoding such as Latin-1.
What formats of hex input are accepted?
All of the ones this tool can produce, and then some. Spaces, commas, line breaks and 0x prefixes are stripped before parsing, so 48656c6c6f, 48 65 6c 6c 6f, 0x48, 0x65 and hex pasted across multiple lines all decode to the same thing.
Why is one character sometimes several hex pairs?
Because hex represents bytes, not characters. In UTF-8, ASCII characters take one byte, most accented Latin and Greek letters take two, most CJK characters take three, and emoji take four. So a 5-character string is not necessarily 10 hex digits: the byte count shown next to the result is the real length.
Is hex the same as Base64?
Both turn bytes into printable text, but hex uses 16 symbols and takes two characters per byte, while Base64 uses 64 symbols and takes roughly 1.33 characters per byte. Hex is easier to read byte by byte, which is why dumps and debuggers use it; Base64 is more compact, which is why it's used for embedding data in JSON, URLs and email.
Is my input sent anywhere?
No. The conversion runs entirely in your browser with plain JavaScript. Nothing you type or paste here is transmitted or stored on any server.