Hex to Binary Converter
Convert hexadecimal values to binary instantly. Supports grouping, prefixes, and batch conversion with a clean copy-to-clipboard interface.
About
Hexadecimal notation compresses binary data by a factor of 4: each hex digit maps to exactly 4 binary bits. Misreading a single nibble - confusing B (1011) with D (1101) - flips two bits simultaneously, which in register-level firmware or network mask configuration causes silent, hard-to-trace failures. This converter performs a deterministic lookup per digit, preserving leading zeros so the output width always equals 4n bits for n hex characters. It handles arbitrary-length input, not just 8-, 16-, or 32-bit words.
The tool assumes unsigned interpretation. It does not infer signedness or endianness - those are context-dependent decisions the engineer must make. For IEEE 754 floats or two's complement integers, convert here first, then apply the sign/exponent logic appropriate to your architecture.
Formulas
The conversion is a direct substitution cipher. Each hexadecimal digit is replaced by its fixed 4-bit binary equivalent from a lookup table T.
Where H is the input hex string of length n, Hi is the i-th character, T is the nibble lookup table mapping 0 - F → 0000 - 1111, and ⋅ denotes string concatenation. The output length is always 4n bits. No arithmetic is performed - the mapping is purely lexical.
For the reverse verification: bin2hex(B) groups the binary string into 4-bit chunks from the right, padding with leading zeros if len(B) mod 4 ≠ 0, then applies the inverse table T−1.
Reference Data
| Hex Digit | Decimal | Binary (4-bit) | Octal |
|---|---|---|---|
| 0 | 0 | 0000 | 0 |
| 1 | 1 | 0001 | 1 |
| 2 | 2 | 0010 | 2 |
| 3 | 3 | 0011 | 3 |
| 4 | 4 | 0100 | 4 |
| 5 | 5 | 0101 | 5 |
| 6 | 6 | 0110 | 6 |
| 7 | 7 | 0111 | 7 |
| 8 | 8 | 1000 | 10 |
| 9 | 9 | 1001 | 11 |
| A | 10 | 1010 | 12 |
| B | 11 | 1011 | 13 |
| C | 12 | 1100 | 14 |
| D | 13 | 1101 | 15 |
| E | 14 | 1110 | 16 |
| F | 15 | 1111 | 17 |
| FF | 255 | 11111111 | 377 |
| 1A | 26 | 00011010 | 32 |
| 7F | 127 | 01111111 | 177 |
| 80 | 128 | 10000000 | 200 |
| FFFF | 65535 | 1111111111111111 | 177777 |
| DEAD | 57005 | 1101111010101101 | 157255 |
| BEEF | 48879 | 1011111011101111 | 137357 |
| CAFE | 51966 | 1100101011111110 | 145376 |
| 0A | 10 | 00001010 | 12 |
| 10 | 16 | 00010000 | 20 |
| 100 | 256 | 000100000000 | 400 |