Binary to Hex Converter

Type a base-2 number and get its hex form, four bits per digit.

    Going the other way? Use the hex to binary converter.

    To convert binary to hex, split the bits into groups of four from the right and replace each group with its matching hex digit. The byte 11010111 splits into 1101 and 0111, which the table maps to D and 7, giving D7.

    How it works

    Hex and binary are unusually good partners because sixteen is a power of two. Every group of four bits, called a nibble, has sixteen possible patterns, and hex has sixteen digits. That means each nibble maps to exactly one hex digit, with no leftover cases and no arithmetic. You are not calculating anything, just substituting from a lookup table.

    Worked example with 11010111. Split from the right into two nibbles: 1101 and 0111. The first is worth 13, which is hex digit D. The second is worth 7, hex digit 7. Read them in order: D7. As a check, the whole byte equals 215 in decimal, and so does D7 read as base 16.

    Splitting from the right matters. If the digit count is not a multiple of four, the incomplete group must be the leftmost one, where padding zeros are harmless. Pad 110101 on the left to 00110101 and it groups cleanly; pad it on the right and you have silently multiplied the number.

    This substitution trick is the whole reason programmers write bytes in hex. A 32-bit value is a wall of digits in binary but only eight characters in hex, and each hex character still tells you the exact bits underneath. Learn the sixteen rows below and you can translate in your head, in either direction, one nibble at a time.

    The nibble table: all 16 hex digits

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

    FAQ

    How do I convert binary to hex?

    Group the binary digits into sets of four starting from the right, then replace each group with its hex digit from the table. The byte 11010111 splits into 1101 and 0111, which map to D and 7, so the answer is D7.

    Why does one hex digit equal four binary digits?

    Because sixteen is two to the fourth power. Four bits have exactly sixteen possible patterns, and hex has exactly sixteen digits, 0 through 9 then A through F. The match is perfect, so conversion is pure substitution with no arithmetic and no carrying involved.

    What if my binary length is not a multiple of four?

    Pad the left side with zeros until it is. The value does not change, since leading zeros add nothing. For example, 110101 pads to 00110101 before grouping. The converter handles this for you, which is why six digits still produce a clean two-digit hex answer.