Encoding / Decoding

Hex Encode / Decode

Convert text to/from hexadecimal (0x or raw hex).

Original
Hex result

What is Hex Encoding?

Hex encoding converts text to hexadecimal representation by bytes, or decodes hex strings back to text. Supports space-separated, continuous, and 0x prefix formats.

Use Cases

  • Binary data inspection and debugging
  • Network packet analysis
  • Cryptographic operations
  • Low-level programming

Frequently Asked Questions

Why does a 2-character Chinese text produce 6 bytes in hex?
Hex encodes UTF-8 bytes, not characters: each Chinese character takes 3 bytes in UTF-8, so two characters are 6 bytes — 12 hex digits. This also makes hex a great debugging tool: garbled text almost always means bytes were decoded with the wrong encoding.
Both hex and Base64 are encodings — how do I choose?
Hex is longer (2 characters per byte) but human-readable and maps directly to memory bytes — ideal for debugging, hash values, and key fingerprints. Base64 is more compact (about 1.33 characters per byte) and better for carrying data through text protocols.
Why does decoding produce garbled output?
Usually the byte sequence is not valid UTF-8 (for example GBK-encoded text), or the hex string contains spaces or 0x prefixes. This tool accepts spaces and 0x prefixes; legacy encodings like GBK need a dedicated encoding converter.