Free browser converter
Hex to Binary Converter
Convert hexadecimal digits to binary bits in your browser with explicit ASCII, Unicode code point, and UTF-8 byte handling.
Interactive tool
Convert hexadecimal digits to binary bits
Ready
Choose the exact representation you need; the tool does not guess an encoding.
Detailed conversion guide
How to Convert Hex to Binary
Hexadecimal uses sixteen digits, so every hex digit maps exactly to four binary bits. Hex 2 becomes 0010, F becomes 1111, A becomes 1010, and 0 becomes 0000.
The converter maps digits directly rather than passing through a floating-point number. That preserves leading zeros and works for inputs longer than JavaScript's safe integer range.
| Input | Output | Meaning |
|---|---|---|
0 | 0000 | one nibble |
A | 1010 | one nibble |
F | 1111 | one nibble |
2F | 0010 1111 | two nibbles |
Hex to Binary in JavaScript and Python
For exact formatting, convert each hexadecimal digit to a four-bit string. Avoid Number for long inputs; direct nibble mapping or BigInt prevents precision loss.
// validate first, then convert
const value = Number.parseInt(token, radix);
if (!Number.isInteger(value)) throw new Error("Invalid input");Leading Zeros, Grouping, and Invalid Hex
Compact output joins all bits. Four-bit output keeps the natural hex nibble boundary, while eight-bit output left-pads to a full byte when needed.
Only digits 0-9 and A-F are valid. Prefixes and separators are syntax; any other character produces a warning instead of a partial conversion.
Related converters
Continue converting ASCII and Unicode
Choose the converter for the direction and representation you need.