Binary to Hex Converter
Type or paste binary and get the hex value as you type, with the decimal value as a check. Switch direction to turn hex back into binary.
4 bits = 1 hex digit
35A
10 bits → 3 hex digits · 2 zeros added on the left · decimal 858
How to Convert Binary to Hex
Hex has 16 digits (0–9, then A–F for ten to fifteen), and four binary digits also have exactly 16 patterns, from 0000 to 1111. So every group of 4 bits is one hex digit, and you can convert without any arithmetic:
- Starting from the right, split the binary number into groups of 4.
- If the leftmost group is short, add zeros to its left until it has 4 digits. This doesn't change the value.
- Swap each group for its hex digit from the chart below.
- Write the hex digits in the same order. That's the answer.
Worked Example: 1101011010 to Hex
A typical homework question: convert 1101011010 to hexadecimal. It has 10 digits, which doesn't divide by 4, so it needs the padding step.
Step 1: Group in fours from the right
Step 2: Pad the short group on the left
Step 3: Look up each group
Step 4: Check it through decimal (optional)
Result: 1101011010 in binary = 35A in hex (858 in decimal). The tool above starts with this number loaded.
Binary to Hex Chart
All 16 groups of 4 bits and the hex digit each one becomes. A quick way to work one out: the four places are worth 8, 4, 2 and 1, so 1011 is 8 + 2 + 1 = 11 = B.
| 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 |
Common Mistakes
| Mistake | Wrong | Right |
|---|---|---|
| Grouping from the left instead of the right | 1101 0110 1000 = D68 | 35A |
| Typing the bits into a decimal-to-hex converter, which reads 1010 as one thousand and ten | 1010 → 3F2 | A |
| Mixing up 1011 (B) and 1101 (D) | 1011 = D | B |
Grouping from the left is the most common one. It adds zeros to the end of the number, which makes it bigger: D68 is exactly 4 times 35A. Extra zeros only ever go on the left. If the number you have is decimal rather than binary, use the number base converter instead.
Converting Binary Bytes and Text to Hex
Binary is often written as a row of 8-digit bytes, such as 01001000 01101001. Each byte becomes two hex digits. Choose the 03 5A format to keep one pair per byte: the result is 48 69, which spells "Hi". To see which letters a row of hex bytes spells, use the UTF-8 converter.
Leave Keep leading zeros on for bytes, so 00001111 gives 0F rather than F. Both are the same number, but a byte is always written with two digits. Each line in the box is converted separately, so you can paste a column of values and copy back a column of hex.
Binary to Hex in Excel, Python, JavaScript and on a Calculator
Each of these turns 11111011 into FB. On Windows you can also use the built-in Calculator: open the menu, choose Programmer, click BIN, type the bits and read the HEX line.
| Tool | How |
|---|---|
| Excel or Google Sheets (up to 10 digits) | =BIN2HEX(A2) |
| Excel or Google Sheets (longer numbers) | =BASE(DECIMAL(A2, 2), 16) |
| Python | format(int(s, 2), 'X') |
| JavaScript | BigInt('0b' + s).toString(16).toUpperCase() |
| Java | new BigInteger(s, 2).toString(16).toUpperCase() |
| C# (up to 64 bits) | Convert.ToInt64(s, 2).ToString("X") |
Excel's BIN2HEX stops at 10 digits and treats a 10-digit number starting with 1 as negative, so use the BASE formula for anything longer. Going the other way? See the hex to binary converter.
Frequently asked questions
How many hex digits does a binary number need?
Divide the number of binary digits by 4 and round up. A byte (8 bits) is 2 hex digits, 16 bits is 4, and 32 bits is 8.
Why do programmers write binary as hex?
Hex is four times shorter than binary but still lines up exactly with the bits. 11111111 is FF in hex, which shows all eight bits are on; 255 in decimal gives no such hint.
Is 1010 the same as A?
Yes. 1010 in binary, A in hex and 10 in decimal are the same number. To show which one you mean, write 1010₂ and A₁₆, or 0b1010 and 0xA in code.
How do I convert binary to octal instead?
Use groups of 3 bits instead of 4, because octal has 8 digits. 1101011010 becomes 001 101 011 010 = 1532 in octal.
Sources
- Microsoft Support: BIN2HEX function: the 10-character limit and negative numbers.
- Python documentation: int(): reading a binary string with base 2.
Related Tools
Convert Base64 encoded data into hexadecimal values.
Convert hexadecimal values into Base64 encoded data.
Convert CMYK color values into HEX color codes.
Convert HEX color codes into CMYK color values.
Convert decimal integers into hexadecimal values.
Convert hexadecimal values into decimal integers.