Four bits, one digit
Binary and hexadecimal are closely linked: 16 is 2⁴, so every hex digit stands for exactly four bits. To convert, split the binary number into groups of four starting from the right, pad the leftmost group with zeros, and replace each group with its hex digit. No arithmetic is needed beyond a 16-entry table, which is why programmers use hex as shorthand for binary.
| Bits | Hex | Bits | Hex |
|---|---|---|---|
| 0000 | 0 | 1000 | 8 |
| 0011 | 3 | 1010 | A |
| 0101 | 5 | 1100 | C |
| 0111 | 7 | 1111 | F |
Worked example
101010 → pad to 0010 1010 → 2 and A → 2A. 1101 1110 1010 1101 → D E A D.
How this works
The page reads the binary digits into an exact big integer and writes it in base 16, which gives the same result as grouping bits in fours from the right. Spaces and underscores in the input are ignored, and a 0b prefix is allowed. You can choose uppercase or lowercase digits and group the output by bytes. The table repeats the value in decimal and octal. Each line converts separately.
Frequently asked
Why do four bits make one hex digit?
Because 2⁴ = 16: four bits have exactly 16 combinations, one for each hex digit 0–F.
What if the number of bits is not a multiple of 4?
Pad on the left with zeros; 101 becomes 0101 = 5.
Does it handle long values?
Yes, any length, exactly.
Is it the same as binary to text?
No. This converts a number. To turn bytes of text into characters, use the binary to text page.
Sources
- ECMA-262 — ECMAScript Language Specification
- ISO 80000-1:2022 — Quantities and units — Part 1: General
- Wikipedia — Hexadecimal
Reviewed Oct 17, 2026 · test vectors fixtures/dev/binary-to-hex/