Hex Encode / Decode
Convert text to and from hexadecimal bytes. UTF-8 safe — handles emoji, Vietnamese, CJK. Configurable separator and 0x prefix.
Hex Encode / Decode
Runs entirely in your browser. Your input never leaves your device.
What next?
How it works
What hex encoding actually is
Hexadecimal encoding represents each byte of binary data as exactly two hexadecimal digits (0–9, a–f). Because one hex digit covers four bits (a nibble), two hex digits cover all 256 possible values of a single byte. The result is a string of ASCII characters that is always twice the length of the original byte sequence.
This is not compression and not encryption — it is purely a display format. Every hex string decodes unambiguously back to the exact bytes it was built from, no key required.
Why hexadecimal, not decimal or octal?
Computers store data in binary (base 2). Hexadecimal (base 16) is a power of two, so each hex digit maps cleanly to exactly four binary bits — a nibble. Decimal does not share that clean alignment, which is why programmers use hex to inspect raw bytes rather than decimal. You'll see this everywhere: 0xFF means 11111111 in binary; 255 in decimal requires three characters and loses the bit-boundary alignment at a glance.
Octal (base 8) has the same two-digit-per-byte problem as decimal for values above 127, which is why it fell out of favour for byte dumps except in some Unix permission displays.
Overhead comparison: Hex vs Base64 vs Binary
| Format | Bytes → output chars | Overhead | |--------|---------------------|----------| | Hex | 1 byte → 2 chars | +100% | | Base64 | 3 bytes → 4 chars | +33% | | Binary | 1 byte → 8 chars | +700% |
Base64 is the winner when minimising wire size matters (JWT, data URIs, MIME attachments). Hex wins when human readability and debuggability of individual bytes matters: a hex dump lets you spot a 0x00 null byte or a 0xFF sentinel at a glance. Binary text is almost exclusively a teaching tool.
Common real-world uses
Memory and file dumps. Debuggers, hex editors (like xxd, hexdump -C), and crash dump tools output hex so developers can inspect raw memory byte by byte. The 0x prefix (0x48 0x65 0x6c 0x6c 0x6f = Hello) is the lingua franca of low-level debugging.
Colour codes. CSS colour #ff6b6b is three one-byte values: red=255, green=107, blue=107. The # replaces 0x as the prefix convention. Every web developer reads hex colour codes dozens of times a day.
MAC addresses. Ethernet hardware addresses are six bytes, conventionally written aa:bb:cc:dd:ee:ff with colons as separators. The Separator option in this tool lets you produce exactly this format.
Cryptographic hash digests. SHA-256 outputs 32 bytes; SHA-512 outputs 64 bytes. Both are almost universally displayed as hex strings — 64 or 128 hex chars. When you see a git commit hash like 4c1502f, that's the first seven characters of a SHA-1 digest in hex.
Ethereum and blockchain. Transaction hashes, wallet addresses, and ABI-encoded calldata are all hex — typically with 0x prefix. The 0x checkbox in this tool toggles that prefix on every byte pair.
Network protocol debugging. Packet captures in Wireshark show payloads as hex. TCP flags in a packet header are a single byte; the hex value 0x12 (SYN+ACK) is far faster to read than 00010010 in binary or 18 in decimal.
The UTF-8 gotcha
When you type a character like é (U+00E9), the text is two UTF-8 bytes: 0xc3 0xa9. If you encode that string to hex expecting one byte per character, you get four hex digits, not two. This is correct — é genuinely occupies two bytes in UTF-8.
An emoji like 😀 (U+1F600) is four UTF-8 bytes: 0xf0 0x9f 0x98 0x80 → eight hex digits. This tool always processes input as UTF-8. If your source system uses a different encoding (Windows-1252, Latin-1), convert to UTF-8 first or the byte values will differ from what this tool produces.
ASCII-only text produces exactly two hex digits per character, because every ASCII codepoint is ≤127 and fits in one byte.
0x prefix convention
The 0x prefix originates in C (the standard was ratified in 1989 as ANSI C / C89). It signals "this literal is hexadecimal" to both the compiler and the reader. The convention spread to almost every language that traces its syntax to C: C++, Java, JavaScript, Go, Rust, Python. In contexts where the base is already implicit (colour codes, MAC addresses, hash outputs), the prefix is dropped and a different separator or length convention marks the field as hex.
Configuring this tool
- Separator — leave blank for a solid hex string (
48656c6c6f), use a space for hex dump style (48 65 6c 6c 6f), use:for MAC address style, use\nfor one byte per line. - 0x prefix — prepend
0xbefore each byte pair, useful for C array literals or Ethereum input. - Case — lowercase is the convention for most Unix tools and crypto output; uppercase matches Windows
certutiloutput and some microcontroller toolchains.
Privacy
All encoding and decoding runs entirely in your browser. Your text or hex string is never sent to a server, never logged, and never leaves your device. Inspect the network tab — you will see zero requests.
Related tools
- Base64 Encode/Decode — lower overhead (33%) for transporting binary over text channels.
- Binary Encode/Decode — eight characters per byte, useful for understanding individual bit positions.
- URL Encode/Decode — percent-encoding for query parameters and URI components.
FAQ
Is hex encoding the same as encryption?
No. Hex encoding is purely a display format — it converts each byte to two readable ASCII characters. Anyone with the hex string can decode it instantly, no key needed. If you need confidentiality, encrypt the data first (AES, ChaCha20), then hex-encode the ciphertext if you need a printable representation. Encoding and encryption are orthogonal concerns.
Why does my character produce four hex digits instead of two?
Because that character is more than one byte in UTF-8. The letter é (U+00E9) encodes to two bytes (0xc3 0xa9), producing four hex digits. An emoji like 😀 (U+1F600) is four UTF-8 bytes — eight hex digits. ASCII characters (codepoints 0–127) always produce exactly two hex digits because they fit in a single byte. This is correct behaviour, not a bug.
When should I use hex instead of Base64?
Choose hex when byte-level readability matters: debugging memory dumps, inspecting cryptographic hashes, reading packet captures, or formatting MAC addresses and Ethernet frames. Base64 is better when minimising size matters — it adds only 33% overhead versus hex's 100%. For most transport use cases (data URIs, JWT, MIME), Base64 is the right tool; for human inspection of raw bytes, hex wins.
What does the 0x prefix mean?
The 0x prefix is a convention from C (standardised in ANSI C89) that marks a numeric literal as hexadecimal. It spread to C++, Java, JavaScript, Go, Rust, and Python. You'll see it in Ethereum addresses, C array literals, and debugger output. In other contexts — CSS colour codes (#ff6b6b) or MAC addresses (aa:bb:cc) — a different separator or delimiter signals the hex format instead.
What separator should I use for MAC addresses?
Use : as the separator and lowercase. The standard MAC address format is six colon-separated byte pairs: aa:bb:cc:dd:ee:ff. Some older networking tools use - as the separator (Windows ipconfig style: AA-BB-CC-DD-EE-FF). Toggle uppercase if the target system requires it. Leave the 0x prefix off — MAC addresses don't use it.
How is hex different from a binary dump?
Hex represents each byte as two characters (100% overhead). Binary represents each byte as eight characters (700% overhead). Both encode the same information. Binary is useful as a teaching tool to see individual bit positions; hex is the practical choice for inspecting real data because it's compact enough to scan at a glance. A 32-byte SHA-256 digest is 64 hex characters but 256 binary characters.
Can I round-trip text with non-ASCII characters?
Yes, as long as both sides agree on UTF-8. This tool encodes your input string to its UTF-8 byte representation, then hex-encodes those bytes. Decoding reverses the process: hex → bytes → UTF-8 string. If the receiving system interprets the bytes as Latin-1 or Windows-1252, the decoded text will differ. Ensure encoding agreement on both ends.
Why do some hex outputs look like 48 65 6c 6c 6f and others like 48656c6c6f?
The only difference is the separator. A space between each byte pair is the style used by xxd, hexdump, and Wireshark — it improves readability for long byte sequences. No separator produces a compact hex string common in hash digests, Ethereum addresses, and URL encoding internals. This tool lets you choose: blank for compact, space for dump style, : for MAC/IPv6 style.