What is Binary to Hex Converter?
This binary to hexadecimal converter and calculator turns base-2 numbers into base-16. Hexadecimal is the compact way programmers write binary data: each hex digit stands for exactly four bits, so the byte 11010110 becomes D6 and 11111111 becomes FF. That makes hex much easier to read than long strings of ones and zeros in memory dumps, color codes, network packets and bit masks.
Paste one value or many separated by spaces, such as 01001000 01101001, and each is converted at once. Options let you choose uppercase or lowercase hex, add a 0x prefix and pick the separator for the output. A full byte keeps its leading zero, so 00001111 becomes 0F.
How to use Binary to Hex Converter
- Enter binary values separated by spaces or commas, for example 11010110
- Read the hexadecimal result instantly.
- Adjust the options: uppercase or lowercase, 0x prefix and output separator.
- Copy the result, or click Swap to convert hex back to binary.
Key features
- Convert many values at once, separated by spaces or commas
- Exact results for numbers of any size, including 64-bit values
- Output separated by spaces, commas, new lines or nothing
- Uppercase or lowercase hex, optional 0x prefix, and binary padded to whole 8-bit bytes
- Swap button to reverse the conversion direction
- Summary of a single value in binary, octal, decimal, hex and ASCII
- Clear errors for invalid digits; runs entirely in your browser
Common use cases
- Converting bit masks and register values to hex for code
- Reading binary data from protocols and file formats
- Turning binary color channels into hex color codes
- Checking homework and exam answers in computer science courses
- Translating binary from microcontroller and embedded documentation
Technical details & standards
To convert by hand, split the binary number into groups of four bits from the right, padding the leftmost group with zeros, and replace each group with its hex digit: 0000 = 0 … 1001 = 9, 1010 = A, 1011 = B, 1100 = C, 1101 = D, 1110 = E, 1111 = F. So 1 0110 1011 becomes 0001 0110 1011 = 16B.
Values separated by spaces or commas are converted one by one, each as a whole number of any length, and a 0b prefix is accepted, so 1101011011111111 gives D6FF while 11010110 11111111 gives D6 FF. The arithmetic uses arbitrary-precision integers, so 64-bit and longer values stay exact. With byte padding on, each hex result has an even number of digits, one pair per byte.
How to convert binary to hex when the bits don't divide by four
Bits to hex works in groups of four, counted from the right. When the length is not a multiple of four, pad the left end with zeros. Here is 1101011011, which has ten bits:
- Count the bits: 10. The next multiple of four is 12, so add two zeros on the left: 001101011011.
- Split into groups of four from the right: 0011, 0101 and 1011.
- Turn each group into one hex digit: 0011 = 3, 0101 = 5, 1011 = B (11).
Result: 1101011011 in binary is 35B in hex (0x35B). Padding on the right instead would change the value, which is the most common mistake.
Binary to hex conversion in Python and JavaScript
Parse the bits as an integer, then print it in base 16. To keep one hex digit for every four bits, including leading zeros, pad the result to the bit length divided by 4.
Python
hex(int("11111111", 2)) # '0xff'
b = "1101011011"
f"{int(b, 2):0{(len(b) + 3) // 4}X}" # '35B'
f"{int('00001111', 2):0{len('00001111') // 4}X}" # '0F', leading zero keptJavaScript
parseInt("11111111", 2).toString(16); // "ff"
BigInt("0b" + "1".repeat(64)).toString(16); // "ffffffffffffffff"Use BigInt for more than 53 bits; parseInt loses precision beyond that.
Binary to hex conversion table
Read binary four bits at a time: each group of four, called a nibble, is one hex digit, from 0000 = 0 to 1111 = F. The second table shows bytes you often meet in binary, split into nibbles, with their hex form.
Every 4-bit group (nibble) in hex
| 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 bytes in binary and hex
| Binary | Hex | Where you see it |
|---|---|---|
| 0000 0001 | 0x01 | Only the lowest bit set |
| 0000 1000 | 0x08 | Bit 3 set, a typical single flag |
| 0010 0000 | 0x20 | ASCII space |
| 0011 0000 | 0x30 | ASCII digit "0" |
| 0100 0001 | 0x41 | ASCII "A" |
| 0110 0001 | 0x61 | ASCII "a" |
| 1100 0000 | 0xC0 | Top two bits set |
| 1111 1110 | 0xFE | Every bit except the lowest |
| 0011 1111 1111 | 0x3FF | Ten bits set, 1023 in decimal |
Frequently asked questions
How do I convert binary to hexadecimal?
Group the bits in fours from the right and convert each group to one hex digit. 10111100 splits into 1011 and 1100, which are B and C, so the answer is BC.
What is 11111111 in hex?
FF. Each group of four ones (1111) is F, and FF is 255 in decimal, the largest value of one byte.
Why do programmers use hex instead of binary?
Hex is four times shorter and maps exactly onto bits: one hex digit is four bits and two hex digits are one byte, so it is easy to convert mentally while being far more readable.
What does the 0x prefix mean?
0x marks a number as hexadecimal in C, JavaScript, Python and most other languages, so 0x1F is 31, not nineteen. Turn on the prefix option to add it to every value.
What are 11110000 and 10101010 in hex?
F0 and AA: 1111 0000 is F and 0, and 1010 1010 is A and A. Other common bytes are 00001111 = 0F, 10000000 = 80 and 11001100 = CC.
What is 1010 in hex?
1010 in binary is A in hex.
What is 101101 in hex?
Pad it to 0010 1101, which is 2D in hex.
What is 0b1010 in hex?
The 0b prefix marks binary, so 0b1010 is 0xA.