0xCONVERTER-HEX

Base 2 → base 16

Binary to Hex Converter

Pack a bit string into hexadecimal. Grouped from the right, padded on the left, with the padding shown so nothing is hidden.

Binary in

Hex

Padded bits

How to convert binary to hex

  1. Start at the right-hand end of the bit string and mark off groups of four.
  2. If the leftmost group has fewer than four bits, pad it with zeros on the left until it does.
  3. Convert each group of four to its single hex digit.
  4. Write the digits in the same left-to-right order as the groups.
Direction matters

Group from the right, not the left. The rightmost bit is the ones place and the grouping must stay anchored to it. Grouping from the left works only by luck, when the bit count happens to divide by four.

Worked examples

1100000011011110      (16 bits, divides evenly)

  1100 0000 1101 1110
   C    0    D    EC0DE


10101001              (8 bits)

  1010 1001
   A    9A9


110111                (6 bits — needs padding)

  group from right:  11 | 0111
  pad the left:    0011 | 0111

  0011 0111
   3    737

Why the padding is safe

Adding zeros to the left of a binary number does not change its value, exactly as writing 42 as 0042 changes nothing in decimal. Those positions carry the highest place values and a zero there contributes zero.

Padding on the right is a different matter: it doubles the value for every bit added. The converter shows the padded bit string alongside the result so you can confirm the zeros went to the correct end.

   110111  =  55
 00110111  =  55   ← padded left, value unchanged
 1101110   = 110   ← padded right, value doubled

Quick reference

HexDecimalBinaryOctal
0000000
1100011
2200102
3300113
4401004
5501015
6601106
7701117
88100010
99100111
A10101012
B11101113
C12110014
D13110115
E14111016
F15111117

Bit counts and what padding tells you

If your bit string does not divide by four, that is usually information rather than a mistake. It often means you are looking at a field extracted from a larger structure, or a value whose leading zeros were dropped when it was printed.

BitsZeros addedHex digits out
1–4up to 31
5–8up to 32
9–12up to 33
1604
3208
64016

Where a fixed width is expected — a register value, a protocol field, a byte in a dump — pad the hex result out to that width with leading zeros too. A 32-bit register value is conventionally written as eight hex digits even when six of them are zero, because the width is part of the meaning.

Input the converter accepts

Bit strings arrive in whatever shape the tool that printed them chose. Spaces every four bits, spaces every eight, commas, or nothing at all — all are accepted and normalised. Anything that is not a 0 or a 1 is reported rather than silently ignored, so a stray character gets caught instead of quietly changing your answer.

Frequently asked questions

How do I convert binary to hex?

Split the bits into groups of four starting from the right, pad the leftmost group with zeros if it is short, then replace each group with its hex digit.

What is 1010 in hex?

A. Four bits set as 1010 equal 10 in decimal, which is written A in hexadecimal.

What if my bit count is not a multiple of four?

Add zeros on the left until it is. Leading zeros never change a binary value, so the result is unaffected.

Why group from the right instead of the left?

The rightmost bit is the ones place, so the grouping must be anchored there. Grouping from the left only gives the right answer when the bit count already divides by four.

How many bits make one hex digit?

Four. Eight bits, or one byte, always becomes exactly two hex digits.

Can I paste binary with spaces in it?

Yes. Spaces, commas, hyphens and line breaks are all removed before conversion.