Hex Encoding: Bytes, Spacing, Case and Common Misdiagnoses

Open Tool Hex Encoder & Decoder

Why developers live in hex

Hex is the plainest way to write a byte: exactly two digits cover all 256 values, unlike binary's eight bits per byte. Inspecting file headers, debugging garbled API output, comparing the first bytes of a hash, documenting protocols and reading binary fields in packet captures all rely on it. One Chinese character is 3 bytes in UTF-8 and therefore 6 hex characters, with 中 written as E4 B8 AD. Holding that ratio in mind settles many mojibake questions instantly.

Steps

  1. Choose the direction: text to hex, or hex to text.
  2. Paste the content. Spaces and line breaks inside hex are ignored.
  3. Enable space between bytes to get E4 B8 AD style grouping for human reading; leave it off for a continuous E4B8AD string for code.
  4. Enable uppercase A-F to normalize case for manual comparison.
  5. Click Convert; Load example runs a sample and Clear resets.

Three reasons decoding fails

Length comes first: hex must contain an even number of digits or bytes cannot be formed. Encoding comes second: valid hex of GBK text rendered as UTF-8 looks garbled, and the fix is to identify the source encoding rather than decode the hex again. Content type comes third: bytes from an image or archive are not text, so a screen of replacement characters is expected.

Details people miss

Leading zeros matter: byte 0A written as A is one digit, giving an odd length and a failed or shifted decode. Case is insensitive but mixing cases makes visual comparison harder, so normalize. Spacing affects manual checking, and byte grouping is the safest convention. If the output is one byte off, check whether 3-byte UTF-8 was mistaken for 2-byte GBK — that confusion causes a lot of wrong conclusions.

⏫︎