Menu

Binary to Hex Converter

Type a binary number and read it in hexadecimal, with each group of four bits shown underneath. It opens on 11010110, which is D6.

By Nethanel Bar, Co-founder & CEO

Last updated

Ready to actually learn to code?

Coddy teaches you by writing real code in your browser - interactive lessons, instant feedback, and AI help when you get stuck.

How to convert binary to hex

Four bits have sixteen combinations, the same number as there are hex digits, so every group of four becomes exactly one hex digit. Work from the right because that is where the groups line up; if the leftmost group is short, add zeros in front of it.

To turn a group into a digit, add the place values of its 1s: 8, 4, 2 and 1. 1101 is 8 + 4 + 1 = 13, which is D, and 0110 is 4 + 2 = 6.

This is why programmers write binary data in hex. A 32-bit value is 32 hard-to-read bits but only 8 hex digits.

What to know about grouping bits

  • Always group from the right, the least significant end.
  • Inside a group, the place values are 8, 4, 2 and 1.
  • Values from 10 to 15 become A to F: 1010 is A and 1111 is F.
  • Grouping by three instead of four gives octal, the system behind chmod numbers.

Binary to hex, worked out

One byte

Binary

11010110

Hex

D6

1101 is 13, written D, and 0110 is 6.

A short number

Binary

101

Hex

5

Pad it to 0101, which is 5.

Nine bits

Binary

1 0110 1011

Hex

16B

Grouping from the right leaves a single 1 on the left, which pads to 0001 and becomes 1.

All ones

Binary

1111 1111 1111 1111

Hex

FFFF

Every group is 1111, so every digit is F. This is 65535, the largest 16-bit value.

Common binary to hex mistakes

  • Grouping from the left. Grouped from the left, 10110 gives 1011 and a stray 0; grouped from the right it is 0001 0110, which is 16.
  • Forgetting to pad the leftmost group with zeros before reading it.
  • Writing 10 to 15 as two digits instead of the letters A to F.
  • Reading a group's bits in the wrong order. The leftmost bit of a group is worth 8.

Binary to hex FAQ

What is 1111 in hex?
F. 1111 is 8 + 4 + 2 + 1 = 15, and 15 is written F.
What is 10000000 in hex?
80. The groups are 1000 and 0000, which are 8 and 0.
How do I convert binary to hex in Python?
hex(int('11010110', 2)) returns '0xd6'. In JavaScript, parseInt('11010110', 2).toString(16) returns 'd6'.
Why group bits in fours?
Because 2 × 2 × 2 × 2 = 16. A group of four bits holds exactly one hex digit, so the conversion is a table lookup with no other arithmetic.

Learn more

Other developer tools

Coddy programming languages illustration

Learn to code with Coddy

GET STARTED