Binary to Hex Converter
Type a binary number to get its hex value. Each group of four bits is shown next to its hex digit.
- Free
- Groups of 4 shown
- Any length
Tip: click any bit to flip it between 0 and 1. The hex updates as you go.
To convert binary to hexadecimal, paste your number in the box above. This binary to hexadecimal converter groups the bits in fours from the right and shows each group’s hex digit, so you can follow the method and check your own work. It’s a quick bin to hex check for whole numbers and fractions. Below: the method, a table, worked examples, fractions, code and five practice questions. For the other bases, see the binary number system guide.
How to convert binary to hex
To convert binary to hex, split the binary number into groups of four bits, starting from the right. Pad the leftmost group with zeros if it has fewer than four bits. Replace each group with its hex digit, 0 to 9 then A to F. For example, 1010 1111 becomes AF.
Four steps, and they work for any whole binary number:
- Group from the right. Count four bits at a time, starting at the last digit.
- Pad the leftmost group with zeros until it has four bits.
- Look up each group in the table below. 0000 is 0, 1001 is 9, 1010 is A, 1111 is F.
- Join the digits in the same order.
Why four? A hex digit has 16 possible values, and four bits have 16 possible patterns (2⁴ = 16). So one hex digit holds exactly one group, no more and no less. Two groups make a byte, which is why a byte is always two hex digits.
Worked example 1, with padding: 100111100 = 13C
100111100 has 9 bits, and 9 isn’t a multiple of 4. Group from the right: 1 0011 1100. The lonely 1 on the left is a short group, so pad it: 0001 0011 1100. Look each one up: 0001 is 1, 0011 is 3, 1100 is C. Join them and you get 13C.
Nine bits is the case textbooks like, and where most wrong answers come from, because people group from the left.
Worked example 2, one byte: 10110101 = B5
Eight bits split cleanly: 1011 0101. 1011 is B (that’s 11 in decimal) and 0101 is 5. The answer is B5.
One more at 9 bits: 110010111 pads to 0001 1001 0111, which is 1, 9, 7, so 197.
Check it with decimal (the long way)
There’s a slower route: convert to decimal first, then to hex. It’s worth doing once, because it proves the shortcut.
100111100 is 256 + 32 + 16 + 8 + 4 = 316 in decimal (see binary to decimal). Divide 316 by 16: 19 remainder 12, and 12 is C. Divide 19 by 16: 1 remainder 3. Read the results from last to first and you get 1, 3, C. Same answer, 13C. Starting from a decimal number instead? Use decimal to binary first, then group.
Binary to hex table
Every 4-bit group, 0000 to 1111, with its hex digit and its decimal value. Learn these sixteen and you can convert any binary number in your head. Tap a row to open it in the converter.
| Binary | 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 |
A byte is two groups, so 1010 1111 is AF. Text works the same way: the bytes 01001000 01101001 are 48 69 in hex, the letters “Hi” (see binary to ASCII).
Numbers people look up most
| Binary | Grouped | Hex |
|---|---|---|
| 100111100 | 0001 0011 1100 | 13C |
| 110010111 | 0001 1001 0111 | 197 |
| 10110101 | 1011 0101 | B5 |
| 10000000 | 1000 0000 | 80 |
| 101101111001010 | 0101 1011 1100 1010 | 5BCA |
| 1010111100100101 | 1010 1111 0010 0101 | AF25 |
Binary fractions to hex
Digits after the binary point follow the same rule, with one twist. Group outward from the point. On the left, pad the first group on the left. On the right, pad the last group on the right.
Take 1101.101. The whole part, 1101, is already a full group: D. After the point, 101 is short, so pad it on the right to 1010, which is A. Put the point back: D.A. In decimal that’s 13.625.
Another: 101.011. The whole part pads to 0101 (5), the fraction pads to 0110 (6). That’s 5.6, or 5.375 in decimal. And 11001.001110 becomes 0001 1001 . 0011 1000, so 19.38.
Zeros always go on the outside, away from the point. Pad the fraction on the left and 101.011 turns into 101.0011, a different number.
Signed and negative binary in hex
Take 11111011. Read as an ordinary unsigned number it’s 251. Read as 8-bit two’s complement it’s −5. In hex it’s FB either way, because hex only rewrites the bits. It doesn’t decide whether they’re negative. In 16 bits, −5 is 1111 1111 1111 1011, which is FFFB. The converter treats a typed minus sign as a plain minus in front of the hex value, not as two’s complement.
Common mistakes
- Grouping from the left. Split 100111100 from the left and you get
100111100, which reads as 9E0. That’s 2528 in decimal. The right answer is 13C, which is 316. Always start at the last digit. - Padding on the wrong side. A single 1 padded on the right becomes 1000, which is 8. Padded on the left it’s 0001, which is 1. A whole number gets its zeros on the left.
- Reading a group as decimal. 1011 is B, not 11. Anything from 1010 up is a letter.
- Dropping leading zeros when the width matters. 1010 is A, but as a full byte, 00001010, it’s 0A. The converter keeps leading zeros you type.
- Typing a digit other than 0 or 1. 10201 isn’t binary. The converter names the character and where it is.
Binary to hex in Python, JavaScript and Excel
| Language | Code | Result |
|---|---|---|
| Python | hex(int('100111100', 2)) | '0x13c' |
| Python | format(int('100111100', 2), 'X') | 13C |
| Python, padded to 4 digits | f"{int('1010', 2):04X}" | 000A |
| JavaScript | parseInt('100111100', 2).toString(16).toUpperCase() | 13C |
| JavaScript, 64 bits | BigInt('0b' + '1'.repeat(64)).toString(16) | ffffffffffffffff |
| Excel | =BIN2HEX(11111011, 4) | 00FB |
| Excel | =BIN2HEX(1110) | E |
Three gotchas. Python’s hex() gives lowercase and a 0x prefix, so use format(..., 'X') when you want plain capitals. In JavaScript, parseInt('0b1010', 2) returns 0, because it stops at the letter b. Strip the prefix, or use Number('0b1010'). And parseInt is only exact up to 53 bits: run it on 64 ones and .toString(16) prints 10000000000000000, not sixteen Fs. Use BigInt for anything long.
Excel is the odd one out. BIN2HEX takes at most 10 bits, and the first is a sign bit. So =BIN2HEX(1111111111) returns FFFFFFFFFF, because 1111111111 is read as −1 and shown as 10 hex characters.
Practice: 5 questions
Work these out by hand, then check against the answers. The converter above shows the steps for any of them.
- 10100011
Check
A3 (1010 → A, 0011 → 3) - 110010111
Check
197 (0001 1001 0111) - 101101111001010
Check
5BCA (0101 1011 1100 1010) - 11110101
Check
F5 (1111 → F, 0101 → 5) - 101.011
Check
5.6 (0101 . 0110)
Frequently asked questions
How do you convert binary to hexadecimal?
Group the bits in fours from the right, pad the first group with zeros, and replace each group with its hex digit. 1010 1111 is AF.
Why do you group binary in fours for hex?
Hex has 16 digits and four bits make 16 patterns (2⁴ = 16), so one hex digit holds exactly one 4-bit group.
What is a nibble?
Four bits. Two nibbles make a byte, which is two hex digits.
What if the number of bits isn’t a multiple of four?
Pad the leftmost group with zeros. 101011 becomes 0010 1011, which is 2B.
Can I convert binary to hex through decimal?
Yes, but it’s slower. 100111100 is 316 in decimal, and 316 in hex is 13C.
What is the difference between binary and hexadecimal?
Both write the same value. Binary uses base 2 with the digits 0 and 1. Hex uses base 16 with the digits 0 to 9 and A to F, and it’s about four times shorter.
How do you write a hex result in code?
Add the 0x prefix: 0x13C.
Why does Excel give FFFFFFFFFF for 1111111111?
BIN2HEX takes up to 10 bits and treats the first as a sign bit, so 1111111111 is read as −1 and shown as 10 hex characters.
Last checked: 24 November 2026. Every example on this page is generated and checked with a script.
Sources: Python docs: int() and format() · MDN: parseInt · MDN: BigInt · Microsoft Support: BIN2HEX · Knuth, The Art of Computer Programming, Vol. 2, §4.1
