Binary Number Tool
Whole numbers only. Very large numbers are handled exactly with BigInt, so there is no rounding from floating point maths.
What Is Binary and What Is Hex
Hexadecimal is base 16, so it uses sixteen symbols: the digits 0 to 9 and the letters A to F. The letter A stands for 10, B stands for 11, C stands for 12, D stands for 13, E stands for 14, and F stands for 15. Because 16 is 2 to the power of 4, one hex digit always stands for exactly four bits. That neat fit is why binary and hex convert into each other so cleanly.
Binary also stores text: each letter is stored as a number, and you can see that with the Text to Binary Converter. Hex is the short form people use when they need to read or write those binary numbers without counting long strings of zeros and ones.
Binary is base 2, using only 0 and 1. Hexadecimal is base 16. The two systems fit together neatly because 16 is 2 to the power of 4, so every hex digit stands for exactly 4 bits.
How to Use This Tool
- Enter a binary number: type digits 0 and 1 only.
- Click Convert: the hex result appears at once, with the 4 bit groups shown.
- Copy the result: paste it into code or a document.
The Method
Converting binary to hex takes four steps. The whole method rests on one fact: every group of 4 bits is exactly one hex digit.
- Pad the binary number on the left with zeros until its length is a multiple of 4.
- Split the padded number into groups of 4 bits, working from right to left.
- Turn each group into one hex digit using the table below.
- Read the hex digits in order from left to right. That string is the answer.
For example, 101010 has six bits, so pad it on the left to 0010 1010. The first group, 0010, is 2, and the second group, 1010, is A. Read them in order to get 2A. If the binary number already has a length that is a multiple of 4, no padding is needed. Try it above: the tool pads the number for you and shows the groups after you press Convert.
Worked Examples
Each row below shows a binary number and its hex value. Work through one row by hand, then check it with the tool above.
| Binary | Hex |
|---|---|
| 101010 | 2A |
| 11111111 | FF |
| 10101111 | AF |
| 11010110 | D6 |
| 1010 | A |
| 1111 | F |
| 10011001 | 99 |
| 10101010 | AA |
| 10000000000 | 400 |
Take 10101111 as a worked example. It already has 8 bits, so no padding is needed. Split it into two groups: 1010 and 1111. The first group, 1010, is A, and the second group, 1111, is F. Read the digits in order to get AF. You can check it by place value: 10101111 in binary is 175 in decimal, and AF in hex is also 175, because 10 times 16 plus 15 is 175.
Binary to Hex Table
This table lists every group of 4 bits and the hex digit it stands for. It is the whole conversion in one place: split any binary number into groups of 4 bits, look up each group here, and join the hex digits.
| 4 bits | Hex digit |
|---|---|
| 0000 | 0 |
| 0001 | 1 |
| 0010 | 2 |
| 0011 | 3 |
| 0100 | 4 |
| 0101 | 5 |
| 0110 | 6 |
| 0111 | 7 |
| 1000 | 8 |
| 1001 | 9 |
| 1010 | A |
| 1011 | B |
| 1100 | C |
| 1101 | D |
| 1110 | E |
| 1111 | F |
Why Use Hex Instead of Binary
Binary strings get long fast. Hex keeps the same information in a quarter of the length, which makes byte values, colour codes, and addresses far easier to read and copy without mistakes.
Where Hex Is Used
Hex shows up wherever computers store or show binary data in a form people can read. Three places use it every day.
Memory addresses. A computer stores data at numbered places in memory, and those addresses are usually written in hex. An address like 7FFF is far easier to read and say than the same value written out as a long string of bits.
Colour codes. Colours on the web are written as six hex digits, two for red, two for green, and two for blue. The colour code FF0000 is pure red: FF for red, 00 for green, and 00 for blue.
Network addresses. A MAC address is written as six pairs of hex digits, and IPv6 addresses are written in hex groups too. Hex keeps these long addresses short enough to read, copy, and compare without mistakes.
Hex is not the only short form for binary. Octal groups bits in threes, and you can convert with the Binary to Octal Converter. To go the other way, from hex back to binary, use the Hex to Binary Converter. To turn binary into decimal instead, use the Binary to Decimal Converter, and to turn a decimal number into hex, use the Decimal to Hex Converter.
Frequently Asked Questions
Yes. It is free, needs no sign up, and runs in your browser.
No. The tool pads the left side with zeros to a multiple of 4 bits automatically.
101010 in binary is 2A in hex, because 0010 is 2 and 1010 is A.
Yes. It uses BigInt, so long binary strings convert exactly.
Because one hex digit is exactly 4 bits, hex is a compact and error resistant way to write binary data.
11111111 in binary is FF in hex. Split it into two groups of 4 bits: 1111 and 1111. Each group is F, so the answer is FF. It is the largest value one byte can hold, which is 255 in decimal.
A byte is 8 bits. Since each hex digit stands for 4 bits, a byte is exactly 2 hex digits. For example, FF is one byte, and so is 00. Two bytes are 4 hex digits, so FFFF is two bytes.
0x is a short marker placed in front of a number to show that the number is written in hex. For example, 0xFF and FF mean the same value. The marker is common in code, so you will see it in programs and in colour codes. This tool accepts plain binary only, so type the binary digits without any prefix.