Binary to Hex Converter: Simple and Powerful

Binary to Hex

Hex to Binary

How it works:

• Binary to Hex: Groups binary digits into sets of 4 bits (nibbles) and converts each nibble directly to its hexadecimal equivalent

• Hex to Binary: Converts each hexadecimal digit directly to its 4-bit binary representation

• Supports common hex formats: with or without '0x' prefix

How the conversion actually works

Binary-to-hex conversion is a grouping trick, not a base-10 detour. Since 16 is 2⁴, every group of 4 binary digits (a "nibble") maps directly to one hex digit — the converter never touches decimal at all. It pads your input on the left with zeros until the length is a multiple of 4, splits it into nibbles, and looks up each nibble's hex value.

Worked example

Take the binary string 10101010. It's already 8 digits, so no padding is needed. Split into two nibbles: 1010 and 1010. Each nibble 1010 in binary is 8+0+2+0 = 10 in decimal, which is A in hex. So both nibbles become A, giving hex AA. As a cross-check, the full binary value 10101010 equals 170 in decimal, and 170 = 10×16 + 10 = AA in hex — same answer, confirming the nibble method.

For hex-to-binary, the same idea runs in reverse: each hex digit expands to exactly 4 binary digits. AA becomes 1010 (for A) followed by 1010 (for the second A), reproducing 10101010.

Input rules

The binary field accepts only 0 and 1 — anything else is rejected before conversion. The hex field accepts 0-9 and A-F (case-insensitive) and understands an optional "0x" prefix, which it strips automatically. Leading zeros in the binary output are trimmed except when a single 0 is the whole result.

Where this matters

Nibble-based hex is the standard way to write memory addresses, color codes (#FF0000 is three bytes, each a pair of hex digits from an 8-bit binary value), and register dumps in low-level debugging — hex is just a shorter, human-readable stand-in for groups of bits.