Binary to Hex Converter
Convert a binary number into hexadecimal, grouping four bits per hex digit.
What the converter returns
You enter a binary numeral and the tool returns the same value in base 16. The defaults are eight ones, 11111111, which convert to FF. Split into two groups of four, the pattern is 1111 1111, and each group is worth 15, which is the hex digit F.
The conversion does not go through decimal in the arithmetic sense, but it does in this implementation: the bits are first accumulated as a number, then written out in base 16. The result is identical either way, because both routes describe the same quantity.
Why four bits make one hex digit
Hexadecimal is base 16 and 16 = 24. A group of four bits has sixteen possible patterns, from 0000 to 1111, and hex has exactly sixteen digits, from 0 to F. The mapping is therefore one to one, with no remainder and no rounding, which is what makes the conversion mechanical rather than arithmetic.
| Bits | Value | Hex | Bits | Value | Hex |
|---|---|---|---|---|---|
| 0000 | 0 | 0 | 1000 | 8 | 8 |
| 0001 | 1 | 1 | 1001 | 9 | 9 |
| 0010 | 2 | 2 | 1010 | 10 | A |
| 0011 | 3 | 3 | 1011 | 11 | B |
| 0100 | 4 | 4 | 1100 | 12 | C |
| 0101 | 5 | 5 | 1101 | 13 | D |
| 0110 | 6 | 6 | 1110 | 14 | E |
| 0111 | 7 | 7 | 1111 | 15 | F |
Octal has the same relationship at three bits, because 8 = 23. Hex won the format war because bytes are eight bits, and eight divides evenly into two groups of four but not into groups of three. Two hex digits map to one byte with no waste; octal would need three digits and leave a spare bit.
The grouping rule
Group from the right, never from the left, because the rightmost bit is the units position. If the leftmost group is short, pad it with zeros on the left. A numeral of seven bits therefore becomes one group of three padded to 0001 plus one full group of four, not the other way around.
Worked example: 11111111 becomes FF
Take the eight bits and split them after the fourth digit from the right: 1111 | 1111. The first group reads 8 + 4 + 2 + 1 = 15, and the second group reads the same, 15. Fifteen is F in hex, so the joined answer is FF.
- 1111 → 8 + 4 + 2 + 1 = 15 → F
- 1111 → 15 → F
- FF expands back as 15×16 + 15 = 255, matching the binary sum
Checking the reverse direction is the same work in the other order. 11111111 has eight set bits, so its decimal value is 255; 255 ÷ 16 = 15 remainder 15, which reads as FF. Three routes, one answer, and any mismatch points to a grouping error rather than a bad rule.
An uneven example: 101101
Six bits do not divide into fours, so pad on the left to eight: 0010 1101. The groups are 0010 = 2 and 1101 = 8 + 4 + 1 = 13 = D, so the hex answer is 2D. As a check, 101101 is 32 + 8 + 4 + 1 = 45, and 2×16 + 13 = 45.
Byte values you will meet
| Binary | Hex | Decimal | Common meaning |
|---|---|---|---|
| 0000 0000 | 00 | 0 | zero, or a null byte |
| 0000 1111 | 0F | 15 | low nibble set, as in a mask |
| 0010 0000 | 20 | 32 | the space character |
| 0111 1111 | 7F | 127 | last ASCII code |
| 1000 0000 | 80 | 128 | first byte above ASCII |
| 1111 1111 | FF | 255 | all bits set, maximum byte |
This table explains a convention you will see everywhere: an eight-bit mask is written 0xFF, and the statement value & 0xFF means keep the low byte and discard everything above it. The same two digits appear as the last pair of a 32-bit color code, where FF means full intensity.
Where the conversion bites
- Grouping from the left instead of the right shifts every digit and changes the value
- Dropping pads makes 0010 1101 look like 10 1101, which no longer splits into nibbles
- The input field is numeric, so typing 11111111 displays as 11,111,111 even though the digits are correct
- A leading-zero pad is invisible in the output when the top group is zero: 0000 1111 is F, not 0F, unless you pad the hex yourself
- Leading zeros vanish from the input before conversion, so an eight-bit pattern can arrive as a shorter numeral
The display quirk catches people who type the value rather than paste it. Because the field holds a number, JavaScript inserts thousand separators for readability; the converter still reads the digits as a bit string, so the output is right as long as every character is a 0 or a 1. Confirm the result against a known pattern such as 1111 1111 → FF before relying on a longer one.
Reading hex where it appears
Hex shows up in four places most developers meet. Color codes are three byte pairs, so #FF6432 is the bytes FF, 64 and 32 — that is 255, 100 and 50 in decimal. MAC addresses are six byte pairs. Hash digests are long runs of hex, where each character is a nibble rather than a full byte. And memory dumps print addresses and contents in hex because each byte takes exactly two characters, which keeps the columns aligned.
Hex versus binary for bit masks
When you are setting individual bits, binary shows the position and hex shows the byte. A mask of 0010 0000 is easy to read as bit 5, while 0x20 is easier to type and copy. Most code uses hex for masks wider than a few bits, and binary in documentation where the position matters.
Range and precision
The input is rounded to a whole number and limited to sixteen digits, so the largest binary entry is sixteen ones, 1111111111111111, which is 65,535 and converts to FFFF. Nothing is lost or approximated at that size, because every value in range is an exact integer.
Above sixteen bits the numeral would need a different tool or a manual split into four-digit chunks. The rule still works, though: break the long string into nibbles from the right, translate each one, and concatenate. A 32-bit value simply produces eight hex digits instead of four.
Frequently asked questions
What is 11111111 in hex?
FF. Split into 1111 and 1111, each group is worth 15, and 15 is F. The value is 255, or 0xFF in code.
How do I convert binary to hex by hand?
Group the bits in fours from the right, pad the leftmost group with zeros if needed, then translate each group to one hex digit using the 0–F table.
Why does one hex digit equal four bits?
Because 16 = 24. Four bits give sixteen patterns and hex has sixteen digits, so the mapping is exact with nothing left over.
What is 1010 1100 in hex?
AC. 1010 is 10, which is A, and 1100 is 12, which is C, so the pair reads AC, decimal 172.
How many hex digits does a byte need?
Two, because a byte is eight bits and eight divided by four is two. That is why byte values are always written as pairs such as 0F or FF.
What is 0x20 in binary?
0010 0000. The 2 becomes 0010 and the 0 becomes 0000, giving 32 in decimal, which is the space character in ASCII.
Why is my output F instead of 0F?
Leading zeros are not kept. 0000 1111 is 15, and 15 is F, so the answer prints as F. Pad to two digits yourself when a byte-aligned format is required.
What is 101101 in hex?
2D. Pad to 0010 1101, read the groups as 2 and 13, and 13 is D. The decimal value is 45.
Is hex case-sensitive?
No. FF and ff are the same value of 255. This converter prints uppercase by convention, which matches most documentation and hex dumps.
Method and sources
- Positional numeral systems, base 2 and base 16.