Binary to Hex Converter
Paste a binary number and get hex. Below the tool, the nibble table shows the digit each group of four bits becomes.
https://flxcode.com/binary-to-hex/
Example
1101 0110 1010 in base 2 (binary) is D6A in base 16 (hexadecimal) (3434 in decimal).
Steps
- Each digit is worth its value times a power of 2: 110101101010 = 1 × 2¹¹ + 1 × 2¹⁰ + 0 × 2⁹ + 1 × 2⁸ + 0 × 2⁷ + 1 × 2⁶ + 1 × 2⁵ + 0 × 2⁴ + 1 × 2³ + 0 × 2² + 1 × 2¹ + 0 × 2⁰ = 3434.
- Divide by 16 again and again. The remainders, read from the last to the first, are the digits: 3434 ÷ 16 = 214 remainder 10 (A); 214 ÷ 16 = 13 remainder 6; 13 ÷ 16 = 0 remainder 13 (D).
The same number in the common bases
| Base | Value |
|---|---|
| base 2 (binary) | 1101 0110 1010 |
| base 8 (octal) | 6552 |
| base 10 (decimal) | 3434 |
| base 16 (hexadecimal) | D6A |
No ads. No account. Nothing you type or record is uploaded. We count page events with a daily code. Check it.
Problem or idea? Email us
Worked examples
| Binary | Hex | Note |
|---|---|---|
| 1111 | F | Four ones are one F |
| 1010 0101 | A5 | A byte becomes two hex digits |
| 1101 0110 1010 | D6A | Twelve bits, three digits |
| 101 | 5 | Short groups are padded on the left: 0101 |
| 1111 1111 1111 1111 | FFFF | The largest 16-bit value |
| 1000 0000 0000 0000 0000 0000 0000 0000 | 80000000 | Bit 31 alone, the sign bit of a 32-bit word |
| 11001 | 19 | Five bits: 1 1001 becomes 0001 1001 |
The by-hand method
- Start at the right end and mark off groups of four bits.
- Add zeros to the left of the last group if it has fewer than four bits.
- Look each group up in the table below.
- Write the digits in the same order.
1011 0110 0011: 1011, 0110, 0011 is B, 6, 3, so the hex number is B63.
The sixteen groups
| 4 bits | Hex | Decimal |
|---|---|---|
| 0000 | 0 | 0 |
| 0001 | 1 | 1 |
| 0010 | 2 | 2 |
| 0011 | 3 | 3 |
| 0100 | 4 | 4 |
| 0101 | 5 | 5 |
| 0110 | 6 | 6 |
| 0111 | 7 | 7 |
| 1000 | 8 | 8 |
| 1001 | 9 | 9 |
| 1010 | A | 10 |
| 1011 | B | 11 |
| 1100 | C | 12 |
| 1101 | D | 13 |
| 1110 | E | 14 |
| 1111 | F | 15 |
Each bit in a group is worth 8, 4, 2 or 1 from left to right. Add the weights of the ones: 1011 is 8 + 2 + 1 = 11, which is B.
Why programmers use it
A long string of bits is hard to read and easy to miscopy. Hex writes the same bits in a quarter of the characters, and every digit maps back to four bits with no arithmetic. Registers, bit masks and memory dumps are usually shown this way. To go the other way use hex to binary. For a decimal result, or for a base such as 8 or 36, open the number base converter.
If you want to do arithmetic on the number, not just rewrite it, the programmer calculator shows hex and binary side by side, with a bit grid you can click.
Numbers this uses
- Digits 0 and 1. Spaces, underscores and a 0b prefix are ignored.
- Up to 1,000 characters, exact (BigInt). Fractions are allowed.
- Groups of four bits are counted from the binary point outward.
Nothing you type is uploaded. We count events without cookies (details).
FAQ
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. Replace each group with its hex digit from the table above. 1011 0110 0011 becomes B, 6, 3, so B63.
Why four bits at a time?
Sixteen is 2 to the power of 4, so one hex digit holds exactly four bits and nothing carries from one group to the next. That is why you never need to add or multiply to do this conversion. You only look up groups.
What if my binary number does not fill a whole number of groups?
Add zeros on the left. 11001 is 1 1001, so pad it to 0001 1001, which is 19 in hex. Leading zeros do not change the value, and the tool pads for you.
Can I type spaces, underscores or a 0b prefix?
Yes. 1111 0000, 1111_0000 and 0b11110000 all give F0. Anything other than 0 and 1 is refused with a message that names the digit.
How do I read a binary number as hex when it is a signed value?
Convert the bit pattern exactly as it is. 1111 1111 is FF whether you call it 255 or -1. The sign only matters when you turn it into a decimal number. The programmer calculator lets you switch between the two readings.
How long a binary number can I convert?
Up to 1,000 characters, converted exactly with BigInt. A 64-bit pattern, 128 bits or a whole hash converts with no rounding.
Does it do binary fractions?
Yes. Put a point in: 1010.1 is A.8 in hex. The places after the point are halves, quarters and so on, and every four of them make one hex digit after the point.
Is my number sent or stored?
No. The conversion runs in your browser. What you type is not put in the address bar, not stored and not counted. We only count the base you converted to.
More from FLXCode
Number Base ConverterNew
Convert any number between bases 2 and 36, exact with BigInt. Negative and fractional input, bits grouped by 4.
Hex to Binary ConverterNew
Turn hexadecimal into binary one digit at a time, with the nibble table. Also octal, decimal and bases up to 36.
Programmer CalculatorNew
Hex, decimal, octal and binary at once with 8 to 64-bit words, AND, OR, XOR, shifts, rotates, a bit grid and RPN.
Long Division CalculatorNew
Long division laid out like on paper, with the remainder and the decimal, repeating part marked.