Binary to Hex

Paste a binary number and see it shrink. Every four bits become one hex digit, and the groups are laid out for you.

Hexadecimal2D7
Decimal727
Octal1327
Try

How it was worked out

Why it takes no arithmetic

Four bits can make exactly sixteen patterns, and hex has exactly sixteen digits, so the two line up perfectly. You don't need to work out what the number is worth. You only swap each group of four for a single digit.

This is the whole reason hex exists in computing. It's binary written in a shorter way, and you can convert back without losing anything.

Convert it in three steps

Let's convert 1011010111.

  1. Split into fours from the right

    That gives 10, 1101 and 0111. Starting from the right matters, because any short group has to end up on the left.

  2. Pad the leftmost group

    10 only has two bits, so add zeros to the front to make 0010. This doesn't change the value.

  3. Swap each group for a digit

    0010 is 2, 1101 is D and 0111 is 7, so the answer is 2D7.

Binary to hex chart

These sixteen rows are all you ever need. Select a pattern to load it above.

BinaryHexDecimal
000000
000111
001022
001133
010044
010155
011066
011177
BinaryHexDecimal
100088
100199
1010A10
1011B11
1100C12
1101D13
1110E14
1111F15

With no chart to hand, use the place values 8, 4, 2 and 1. For 1101, that's 8 + 4 + 1 = 13, and 13 is D. After the digit 9, the letters count on from A = 10.

How much shorter does it get?

Every data size in computing is a multiple of four bits, so sizes convert neatly into a whole number of hex digits.

SizeBitsHex digitsLargest value
Nibble41F
Byte82FF
16-bit word164FFFF
32-bit word328FFFFFFFF
64-bit word6416FFFFFFFFFFFFFFFF

Half a byte has its own name, a nibble, which is one hex digit. That's why you'll always see a byte written as two digits, in colour codes and in memory dumps alike.

Where the conversion helps

1111 0000 = F0

Bit masks

You can read a mask at a glance in hex. F means all four bits on, and 0 means all four off, so F0 keeps the top half of a byte.

0100 = 4

Spotting single flags

A digit of 1, 2, 4 or 8 means just one bit is on in that group. That helps when you're reading status registers and settings.

1100 0000 = C0

Reading memory

Debuggers show memory in hex because a screen full of raw bits is impossible to scan. Eight digits fit a value that would take 32 bits.

101 101 = 55

Octal works the same way

Octal uses groups of three instead of four, because one octal digit is three bits. 101101 is 55 in octal and 2D in hex.

Where answers usually go wrong

Grouping from the left

This is the classic slip. 1011010 is 101 1010, or 5A. Group it from the left as 1011 010 and you get B2, which is a different number.

Padding the wrong end

Add zeros on the left only. Adding them on the right multiplies the number, so 101 becoming 1010 changes 5 into 10.

Skipping a group of zeros

1111 0000 1111 is F0F. Every group gets a digit, including the empty-looking one in the middle.

Mixing up B and D

B is 1011 and D is 1101. They look alike and they're the two most commonly swapped. Check them with 8-4-2-1 if you're unsure.

Try these yourself

Work each one out on paper before you open it.

What is 11110000 in hex?

F0. The groups are 1111 and 0000.

What is 10101 in hex?

15. The groups are 1 and 0101, and the first pads to 0001. Note that this is hex 15, which equals 21 in decimal.

What is 1100100 in hex?

64. The groups are 110 and 0100, and the first pads to 0110. This is hex 64, which equals 100 in decimal.

Common questions

What is 1111 in hex?

It's F, the largest single hex digit.

What is 11111111 in hex?

It's FF, which is 255 in decimal and the largest value of one byte.

Why group in fours and not some other size?

Because 2 to the power of 4 is 16, so four bits match one hex digit exactly. Any other size wouldn't line up.

Does the answer change if my binary has spaces?

No. Spaces, underscores and a 0b prefix are ignored, so you can paste binary in any grouping you like. Zeros at the very front are dropped from the hex answer.

How long can the binary number be?

Up to 16,384 bits, with no rounding. The working is shown for up to 64 bits.

Is my number sent anywhere?

No. The conversion runs in your browser, so it never reaches our server. A link you copy from the address bar can contain the number.