Hex to binary: see every bit
This hex to binary converter expands hexadecimal numbers into the bit patterns they stand for. It is the quickest way to check which flags are set in a register, which bits a mask keeps, or how a byte is laid out.
One hex digit, four bits
Replace each hex digit with its 4-bit pattern and join them. The digit 0 is 0000, 7 is 0111, A is 1010 and F is 1111. No carrying or division is needed.
1F4
1 → 0001
F → 1111
4 → 0100
= 0001 1111 0100 → 111110100
Without grouping, the converter drops leading zeros and shows 111110100. With Group digits set to Nibbles, the whole-number part is padded to a multiple of four and shown as 0001 1111 0100, so each block sits under the digit it came from.
Example
Input Output
A 1010
FF 11111111
1F4 111110100
7FFFFFFF 1111111111111111111111111111111 (31 ones)
A.8 1010.1
For fractions, the digits after the point expand the same way. A.8 is 1010.1000, and trailing zeros after the point are removed, giving 1010.1.
Decoding flags and masks
Suppose a status register reads 0x2F. Expanding it gives 0010 1111, so bits 0, 1, 2, 3 and 5 are set (counting from the right, starting at 0) and bits 4, 6 and 7 are clear.
A network mask of 0xFFFFFF00 expands to twenty-four 1s followed by eight 0s, which is a /24 prefix, the same as 255.255.255.0. For full subnet details, the CIDR calculator does the rest.
Input tips
- 0x and # prefixes are stripped, and upper or lower case both work.
- Spaces are ignored, so DE AD BE EF and DEADBEEF give the same 32-bit pattern. The field holds one value at a time.
- 7FFFFFFF shows 31 bits because the leading zero of the top nibble is not printed. Turn on grouping to see all 32.
Common mistakes
- Writing inner digits with fewer than four bits. 0x1F must become 0001 1111; if the F were written as 111 the value would change.
- Counting bits from the left. Bit 0 is always the rightmost, least significant bit.
Related conversions
Go back with binary to hex, or get the numeric value with hex to decimal. If you want to apply AND, OR or XOR to hex values and see the bits line up, the bitwise calculator prints both operands and the result in binary.
Hex to binary in code and spreadsheets
- Python:
bin(0x1F4)returns'0b111110100';format(0x1F4, '016b')pads it to 16 bits. - JavaScript:
(0x1F4).toString(2).padStart(16, '0'). Above 53 bits, switch toBigInt('0x' + hex).toString(2)so no bits are lost. - C++:
std::bitset<16>(0x1F4)prints a fixed-width pattern including leading zeros. - Excel and Google Sheets:
=HEX2BIN("1F4")works only up to1FF, because the result may have at most 10 bits, so wider values need splitting.
The converter has none of these width limits and updates as you type, which makes it convenient for checking register maps, datasheet tables and test vectors one value at a time.