How to use the hex to binary
- Type or paste a hexadecimal string into the input field. You may include a
0xprefix; it will be ignored during conversion. - Choose how to group the output bits: no grouping, every 4 bits (one nibble) or every 8 bits (one byte).
- Toggle the Add 0b prefix checkbox if you need the standard binary literal format used in many programming languages.
- Select uppercase or lowercase for the prefix letters. The binary digits themselves are always 0 and 1.
- The binary result updates instantly as you type. Copy it directly from the output area.
How hex to binary conversion works
Each hexadecimal digit maps to exactly four binary digits (a nibble). Because 16 is a power of 2, the conversion is direct: you replace each hex character with its four-bit equivalent rather than performing arithmetic division.
The mapping is fixed:
| Hex | Binary |
|---|---|
| 0 | 0000 |
| 1 | 0001 |
| 5 | 0101 |
| A | 1010 |
| F | 1111 |
To convert 1A3F, replace each digit: 1 becomes 0001, A becomes 1010, 3 becomes 0011 and F becomes 1111. Concatenating them gives 0001101000111111. Leading zeros on the very first nibble are typically dropped unless you need a fixed bit width, so the result is 1101000111111.
Reference table for all hex digits
This table shows every valid hexadecimal character and its four-bit binary equivalent. Use it to verify manual conversions or to understand the pattern behind the hex to binary mapping.
| Hex | Binary | Decimal value |
|---|---|---|
| 0 | 0000 | 0 |
| 1 | 0001 | 1 |
| 2 | 0010 | 2 |
| 3 | 0011 | 3 |
| 4 | 0100 | 4 |
| 5 | 0101 | 5 |
| 6 | 0110 | 6 |
| 7 | 0111 | 7 |
| 8 | 1000 | 8 |
| 9 | 1001 | 9 |
| A | 1010 | 10 |
| B | 1011 | 11 |
| C | 1100 | 12 |
| D | 1101 | 13 |
| E | 1110 | 14 |
| F | 1111 | 15 |
Why group bits into nibbles or bytes
A long string of ones and zeros is difficult to read. Grouping the output makes it easier to cross-reference with the original hex value or to identify specific fields in a binary protocol.
- Nibble grouping (4 bits): Each group corresponds to one hex digit. This is the most natural way to read a hex to binary conversion because you can map each group back to its source character.
- Byte grouping (8 bits): Useful when working with memory addresses, network packets or file formats where data is organized in bytes. Two hex digits always form one byte.
- No grouping: Produces a continuous string suitable for pasting into code or feeding into another tool like a bitwise calculator.
Handling large hexadecimal values
Standard JavaScript numbers lose precision beyond 53 bits. This converter uses BigInt internally, so you can paste hex strings of any length, such as cryptographic hashes or UUIDs, and get an exact binary representation without rounding errors.
For example, a SHA-256 hash is 64 hex characters long, representing 256 bits. Converting it with standard floating-point math would corrupt the least significant bits. With BigInt, every bit is preserved exactly. If you need to work with the numeric value of that hash in base 10, use the hex to decimal tool instead.
Common mistakes to avoid
When converting hex to binary manually, a few errors come up frequently:
- Dropping leading zeros within a nibble: The hex digit
3must become0011, not11. Only the leading zeros of the very first digit may be dropped. - Confusing hex letters with variables: In hex,
AthroughFrepresent values 10 through 15. They are not algebraic variables. - Mixing up prefixes:
0xdenotes hexadecimal in C-style languages, while0bdenotes binary. Adding0xto a binary string will cause parser errors in most environments. - Ignoring case sensitivity in strict parsers: While this tool accepts both upper and lowercase hex input, some programming languages or protocols require a specific case.
Worked examples
| Example | Input | Result |
|---|---|---|
| Single byte | Hexadecimal input: FF; Group bits: 4; Add 0b prefix: no; Letter case: lower | 1111 1111 |
| With 0x prefix | Hexadecimal input: 0x1A3F; Group bits: 4; Add 0b prefix: yes; Letter case: lower | 0b 0001 1010 0011 1111 |
| Large number grouped by bytes | Hexadecimal input: DEADBEEF; Group bits: 8; Add 0b prefix: no; Letter case: upper | 11011110 10101101 10111110 11101111 |
| Zero | Hexadecimal input: 0; Group bits: none; Add 0b prefix: no; Letter case: lower | 0 |
FAQ
How do I convert hex to binary?
Replace each hexadecimal digit with its four-bit binary equivalent. For example, hex 2F becomes 0010 1111. You can drop the leading zeros on the first group, giving 101111.
Why does each hex digit equal four binary digits?
Hexadecimal is base 16, and binary is base 2. Since 16 equals 2 raised to the power of 4, exactly four binary bits are needed to represent every possible hex digit from 0 to F.
Can this tool handle very large hex strings?
Yes. The converter uses BigInt arithmetic, so it processes hex strings of any length without losing precision. This is useful for cryptographic hashes and large identifiers.
What does the 0b prefix mean?
The 0b prefix is a convention used in languages like Python, JavaScript and C++ to indicate that a literal number is written in binary format. It prevents confusion with decimal or hexadecimal literals.
Is my data sent to a server when I use this tool?
No. The hex to binary conversion runs entirely in your browser. Nothing you type is uploaded or stored anywhere.
How do I go from binary back to hex?
Group the binary string into sets of four bits starting from the right, then replace each group with its hex digit. You can also use the binary to hex converter for instant results.
Should I keep leading zeros in the binary output?
It depends on your use case. For mathematical values, leading zeros do not change the number and can be dropped. For fixed-width representations like memory addresses or color channels, keep them to maintain the correct bit length.