Boneyard Tools

Hex, binary and the nibble: how base 16 lines up with base 2

Why one hex digit equals four binary bits, how nibbles keep long values readable, and when to pad binary output to fixed-width groups.

Base 16 is shorthand for base 2

Hexadecimal exists because raw binary is exhausting to read. Sixteen is a power of two (two to the fourth), so every hex digit stands for a fixed block of four binary bits. That clean factor is what lets you split a hex string into digits, translate each into its four-bit pattern, and glue the pieces back together without any carrying or arithmetic. A byte, being eight bits, is therefore always exactly two hex digits, which is why colors, memory addresses and file dumps are written in hex.

The nibble is the unit that matters

A nibble is four bits, and it is the bridge between the two number systems. The value 0 fills a nibble with 0000 and the value 15 fills it with 1111, covering every pattern in between. When you read binary in nibble-sized chunks it becomes far easier to spot the matching hex digit, because 1010 is always A and 1100 is always C. This tool works on the whole number at once using BigInt, but the mental model of four bits per digit is what makes the output verifiable by eye.

Why leading zeros disappear, and when to pad

A number has no built-in notion of how wide it should be, so binary drops any zeros on the left. Hex 5 is mathematically the same value as 0101, and toString(2) returns the shorter 101. That is correct as a number but awkward when you are lining up nibbles or bytes for a diagram. The 'Pad to 4-bit groups' option pads the result up to the next multiple of four bits so each nibble stays a full four characters, which keeps columns aligned when you compare several values.

Where this conversion shows up

Reading binary out of hex is a daily task in low-level work. Bitmask and flag registers are documented in hex but reasoned about bit by bit, so expanding them to binary shows exactly which flags are set. Network engineers expand hex to check subnet and MAC bit boundaries, and anyone poking at file formats expands magic-number bytes like DEADBEEF to inspect individual bits. Because the tool ignores spaces and the 0x prefix, you can paste bytes straight from a hex editor and read the binary without cleanup.

Frequently asked questions

Is hex to binary lossless?

Yes. The two bases represent the same integer, so converting hex to binary and back returns the original value. The only visible change is that unpadded binary omits leading zeros unless you enable padding.

How many bits does one hex digit produce?

Exactly four, when padded. Without padding the most significant digit may show fewer bits because leading zeros are trimmed, but every digit after it still expands to a full four-bit nibble.

Can I convert binary back to hex here?

This tool goes one direction, hex to binary. For the reverse, use a binary-to-hex converter, which groups the bits back into nibbles and maps each to a single hex digit.