Base 2 → base 16
Binary to Hex Converter
Pack a bit string into hexadecimal. Grouped from the right, padded on the left, with the padding shown so nothing is hidden.
How to convert binary to hex
- Start at the right-hand end of the bit string and mark off groups of four.
- If the leftmost group has fewer than four bits, pad it with zeros on the left until it does.
- Convert each group of four to its single hex digit.
- Write the digits in the same left-to-right order as the groups.
Group from the right, not the left. The rightmost bit is the ones place and the grouping must stay anchored to it. Grouping from the left works only by luck, when the bit count happens to divide by four.
Worked examples
1100000011011110 (16 bits, divides evenly) 1100 0000 1101 1110 C 0 D E → C0DE 10101001 (8 bits) 1010 1001 A 9 → A9 110111 (6 bits — needs padding) group from right: 11 | 0111 pad the left: 0011 | 0111 0011 0111 3 7 → 37
Why the padding is safe
Adding zeros to the left of a binary number does not change its value, exactly as writing 42 as 0042 changes nothing in decimal. Those positions carry the highest place values and a zero there contributes zero.
Padding on the right is a different matter: it doubles the value for every bit added. The converter shows the padded bit string alongside the result so you can confirm the zeros went to the correct end.
110111 = 55 00110111 = 55 ← padded left, value unchanged 1101110 = 110 ← padded right, value doubled
Quick reference
| Hex | Decimal | Binary | 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 |
Bit counts and what padding tells you
If your bit string does not divide by four, that is usually information rather than a mistake. It often means you are looking at a field extracted from a larger structure, or a value whose leading zeros were dropped when it was printed.
| Bits | Zeros added | Hex digits out |
|---|---|---|
| 1–4 | up to 3 | 1 |
| 5–8 | up to 3 | 2 |
| 9–12 | up to 3 | 3 |
| 16 | 0 | 4 |
| 32 | 0 | 8 |
| 64 | 0 | 16 |
Where a fixed width is expected — a register value, a protocol field, a byte in a dump — pad the hex result out to that width with leading zeros too. A 32-bit register value is conventionally written as eight hex digits even when six of them are zero, because the width is part of the meaning.
Input the converter accepts
Bit strings arrive in whatever shape the tool that printed them chose. Spaces every four bits,
spaces every eight, commas, or nothing at all — all are accepted and normalised. Anything that
is not a 0 or a 1 is reported rather than silently ignored, so a stray
character gets caught instead of quietly changing your answer.
Frequently asked questions
How do I convert binary to hex?
Split the bits into groups of four starting from the right, pad the leftmost group with zeros if it is short, then replace each group with its hex digit.
What is 1010 in hex?
A. Four bits set as 1010 equal 10 in decimal, which is written A in hexadecimal.
What if my bit count is not a multiple of four?
Add zeros on the left until it is. Leading zeros never change a binary value, so the result is unaffected.
Why group from the right instead of the left?
The rightmost bit is the ones place, so the grouping must be anchored there. Grouping from the left only gives the right answer when the bit count already divides by four.
How many bits make one hex digit?
Four. Eight bits, or one byte, always becomes exactly two hex digits.
Can I paste binary with spaces in it?
Yes. Spaces, commas, hyphens and line breaks are all removed before conversion.