Hex to binary converter
Type hex to get binary. Each hex digit becomes four bits.
Prefixes 0b, 0o, 0x and spaces or underscores between digits are fine. A point starts the fraction.
How to convert hex to binary
Replace each hex digit with its four-bit pattern from the table and join the groups. D is 1101 and 6 is 0110, so D6 is 1101 0110. You can drop leading zeros from the very first group if you don’t need a fixed width.
Hex to binary chart
| Hex | Binary | Hex | Binary |
|---|---|---|---|
| 0 | 0000 | 8 | 1000 |
| 1 | 0001 | 9 | 1001 |
| 2 | 0010 | A | 1010 |
| 3 | 0011 | B | 1011 |
| 4 | 0100 | C | 1100 |
| 5 | 0101 | D | 1101 |
| 6 | 0110 | E | 1110 |
| 7 | 0111 | F | 1111 |
Common mistakes
Dropping leading zeros of a digit
Writing 3 as 11 inside a number, so 3F becomes 11 1111
Instead: Write every hex digit as four bits: 3F is 0011 1111
Mixing up B and D
B is 1011 (11); D is 1101 (13)
Instead: Use the table above, or count up from A = 1010
Reading 0x as digits
Treating the x in 0x1F as a digit
Instead: 0x only marks the number as hex; ECMA-262 also uses 0b and 0o for binary and octal
Where you read hex as bits
Flags and masks: the value 0x05 sets bits 0 and 2 (0000 0101), and AND-ing a byte with 0x0F keeps its low four bits. The bit workbench lets you click the bits of any hex value to see what each one means.
Sources and method
- ECMA-262, ECMAScript Language Specification, section 12.9.3 Numeric Literals: the 0b, 0o and 0x prefixes for binary, octal and hex. Checked 2026-11-25.
Conversions use exact whole-number arithmetic (JavaScript BigInt), so long numbers keep every digit. Fractions are kept as exact ratios; when the digits repeat, the repeating block is found and marked instead of rounded.
Questions
Why does each hex digit become exactly four bits?
Because 16 = 24. Four bits can hold 16 values, 0000 to 1111, which match the 16 hex digits 0 to F.
How do I keep leading zeros?
Tick “Read as signed” and pick a width; the result is then shown at that full width, for example 0x1F as 00011111 in 8 bits.
Can I paste hex bytes from a dump?
For a single number, yes. To turn a list of hex bytes into text, paste them into the binary translator on the home page, which reads hex byte pairs.