Hex Encoder & Decoder
Two hex characters per byte, in both directions.
Why hex exists
One byte is eight bits, and one hex digit is four bits — so a byte is always exactly two hex characters, with no padding rules and no ambiguous grouping. That one-to-one alignment is why hex, not decimal, is the notation for digests, memory addresses, colour values, and byte dumps.
Encoding goes through UTF-8, not code points
The letter A is byte 0x41, one byte, 41. The character 中 is U+4E2D, which UTF-8 encodes as three bytes E4 B8 AD, printed as e4b8ad. An emoji like 🚀 (U+1F680) becomes four bytes F0 9F 9A 80, printed as f09f9a80. Hex is a view of bytes, so the byte length of a string is not its character count.
Where you meet hex strings
- Digests — SHA-256 output, as in the hash tools on this site, is 32 bytes rendered as 64 hex characters.
- Colour literals —
#1a56dbis three hex bytes: red0x1a, green0x56, blue0xdb. - Byte escaping — URLs use
%E4%B8%AD, Windows paths and Windows Registry use the same idea. - Protocol dumps — packet captures, TLV payloads, and hardware registers are printed as hex byte rows.
Case, separators, and the odd-length error
Case is cosmetic: E4B8AD and e4b8ad are the same bytes, and any correct decoder accepts both. Separators such as spaces, colons, or 0x prefixes appear in logs and dumps; a good decoder strips them, but the strictest output form — no separators, lowercase — is what you should store and compare, because a byte-for-byte comparison of two differently formatted hex strings fails even when the bytes are identical.
A hex string with an odd number of characters cannot be decoded: half a byte is not a byte. It almost always means a character was dropped in a copy-paste, and the decoder should tell you the length rather than silently guess.
How to use it
- Paste text to encode, or a hex string to decode.
- Read the byte count alongside the result.
- Strip separators if a downstream tool requires a bare string.
Worth knowing
- Two hex characters always represent exactly one byte.
- UTF-8 uses one byte for ASCII, three for most CJK characters, four for emoji and rare scripts.
- Hex is not a number base you should store in — it is a byte notation, not arithmetic.
- Padding matters for numerals (
0x0Ais one byte;0x0A0Bis two).
Limitations
- Hex doubles the size of ASCII text, worse than Base64's 33 percent overhead.
- Mixed-case hex is a valid byte string but a poor comparison key.
- Odd-length input is an error, not something a decoder should repair.
- Hexadecimal numerals and hex byte strings look alike but mean different things.
Frequently asked questions
How many hex characters is one byte?
Why is my Chinese text so many hex bytes?
Is lowercase or uppercase hex better?
sha256sum prints; uppercase is common in hardware documentation. Pick one for storage and normalise on input.Can I decode hex without separators?
0x prefixes are display conveniences and should be stripped before decoding.