Hex Encoder Decoder
Convert text to hexadecimal and back. Supports uppercase/lowercase, with or without byte separators.
- Home
- > Encoder & Decoder >
- Hex Encoder & Decoder
Encode
Decode
What is Hexadecimal Encoding?
Hexadecimal (or hex) is a base-16 number system that uses sixteen distinct symbols: 0-9 to represent values 0-9, and A-F (or a-f) to represent values 10-15. Hex encoding converts binary data into a human-readable string of hex digits.
Each byte (8 bits) is represented by two hex digits. For example, the byte value 255 is represented as FF in hex, and the ASCII character A (decimal 65) is represented as 41.
Why Use Hex Encoding?
- Readable representation of binary data for debugging
- Compact notation for memory addresses and color values
- Safe transmission of binary data in text-based protocols
- Common in low-level programming, networking, and cryptography
- Used in URL encoding for non-ASCII characters (%20 = space)
How to Use This Hex Encoder/Decoder
- Encode text — Type or paste text into the left panel, then click Encode to convert it to hexadecimal.
- Decode hex — Type or paste hex values into the right panel, then click Decode to convert them back to text.
- Toggle options — Use Uppercase for A-F output, Add spaces for readable byte separation.
- Swap & Clear — Click Swap to exchange encode/decode values, Clear All to reset everything.
Common Use Cases
- Debugging binary data — Inspect raw bytes in memory dumps, network packets, or file headers using hex representation.
- Color values — CSS colors use hex notation (#FF5733), making hex encoding essential for web design.
- Cryptography & hashing — Hash outputs (MD5, SHA) are commonly displayed as hex strings.
- Data transmission — Encode binary data for text-based protocols like JSON, XML, or HTTP headers.
- Memory addresses — Debuggers and profilers display memory addresses in hexadecimal for easy reading.
Frequently Asked Questions
What is the difference between hex encoding and Base64?
Hex encoding uses 2 characters per byte (16×16 = 256 values), making the output twice the size of the input. Base64 uses 4 characters per 3 bytes (64×64×64×64 = 16M values), about 33% larger. Hex is more human-readable; Base64 is more space-efficient.
Does this tool support Unicode characters?
Yes, but this tool uses UTF-16 code units (JavaScript's native string encoding). Characters in the Basic Multilingual Plane (BMP) encode to 2 hex bytes per character. Supplementary characters (emojis, rare scripts) will encode to 4 hex bytes (2 surrogate pairs).
Can I decode hex with or without spaces?
Yes. The decode function automatically handles hex strings with spaces, without spaces, or with 0x or \x prefixes. It strips non-hex whitespace and processes the remaining hex digits.
What happens if I enter invalid hex characters?
Non-hexadecimal characters (anything except 0-9, A-F, a-f, and whitespace) are ignored during decode. If no valid hex digits remain, the output will be empty.
Why does 1 byte = 2 hex characters?
A byte is 8 bits. Each hex digit represents 4 bits (0-15). So 8 bits ÷ 4 bits per hex digit = 2 hex digits per byte. The maximum value FF (hex) = 255 (decimal) = 11111111 (binary).