Hex Encoder/Decoder
Hexadecimal (hex) encoding represents binary data using 16 symbols (0-9 and A-F). Each byte becomes two hex characters. This tool decodes hex strings to reveal the original content, identifies file types using magic bytes, and provides a hex editor-style viewer for binary inspection.
Common Use Cases
- Decode hex-encoded data from APIs and logs
- Inspect binary file headers and magic bytes
- Analyze network packet payloads
- Debug cryptographic values (hashes, keys, IVs)
- View raw binary data from databases or files
- Convert hex dumps from debugging tools
Features
- Decode hex strings in multiple formats (plain, spaced, 0x-prefixed, colon-separated, C-array)
- Hex viewer with offset, hex bytes, and ASCII representation
- Auto-detect decoded content type (JSON, XML, text, etc.)
- Chain detection — auto-detect decoded content with "Decode as X" button
- File type identification using magic bytes for binary data
- Virtual scrolling for large files with lazy chunk loading
- Convert between hex formats (plain, spaced, 0x, colon, C-array)
- Encode text to hex in various formats
Examples
Tips
- Hex encoding doubles the size of data (each byte becomes 2 characters).
- Common magic bytes: PDF starts with 25504446 (%PDF), ZIP with 504B0304.
- Image data (PNG, JPEG, etc.) is auto-detected and uses the Image Analyzer tool.
- The 0x prefix indicates hexadecimal in most programming languages.
- MAC addresses and UUIDs use colon or hyphen separators.
- Hex is case-insensitive: 0xFF equals 0xff.
Understanding Hex Encoder/Decoder
Hexadecimal (hex) encoding represents binary data using base-16 notation, where each byte maps to exactly two characters from the set 0-9 and A-F. This direct byte-to-text mapping makes hex the standard representation for binary data in debugging, cryptography, networking, and low-level programming.
Unlike Base64, which obscures byte boundaries with its 6-bit grouping, each pair of hex characters maps to exactly one byte, making it trivial to read individual values. Memory addresses, register contents, network packet dumps, file headers, and cryptographic values are all conventionally displayed in hex.
Hex strings appear in many formats. Plain hex (48656c6c6f) is common in APIs. Space-separated hex (48 65 6c 6c 6f) appears in packet captures. Colon-separated hex (48:65:6c:6c:6f) is used for MAC addresses and certificate fingerprints. The 0x prefix (0x48, 0x65) is the standard hex literal in C, JavaScript, Python, and most languages. C-style arrays ({0x48, 0x65}) embed binary data in source code.
File type identification relies on magic bytes — specific hex sequences at the start of a file that identify its format. PDFs begin with 25504446 (%PDF), PNGs with 89504E47, ZIPs with 504B0304, and ELF executables with 7F454C46. Recognizing these signatures is essential for debugging file handling code and analyzing binary data.
Hex and Base64 both encode binary data as text, but they make different tradeoffs. Hex maps each byte to 2 characters, doubling the data size (100% overhead), while Base64 maps every 3 bytes to 4 characters with only about 33% overhead. Base64 is more space-efficient for large data, making it the better choice for embedding binary content in text formats. Hex is more readable for byte-level inspection, making it the standard for debugging, cryptographic values, and protocol analysis where individual byte values matter.
Magic bytes (also called file signatures) are specific byte sequences at the very beginning of a file that identify its format regardless of the file extension. PNG files start with 89 50 4E 47, JPEG with FF D8 FF, and ZIP with 50 4B 03 04. The Unix "file" command relies on magic bytes to detect file types, and the same technique is used in this tool to identify binary content within hex data.
Hex is case-insensitive because the digits A-F represent values 10-15 regardless of whether they are uppercase or lowercase — 0xFF and 0xff both mean decimal 255. The choice between cases is purely conventional: uppercase is common in specifications and hash output, while lowercase is common in web development contexts like CSS colors and URL encoding. The 0x prefix indicates a hexadecimal number literal in most programming languages, including C, C++, Java, JavaScript, Python, Go, and Rust. Without the prefix, a value like "10" would be ambiguous between decimal and hex; writing 0x10 makes it unambiguously hexadecimal (decimal 16).