How to use the binary to hex converter
- Select the conversion direction: binary to hexadecimal or hexadecimal to binary.
- Type or paste your value into the input field. Spaces are ignored automatically.
- The result updates live as you type. Copy it directly from the output area.
How binary to hex conversion works
Binary (base 2) uses only the digits 0 and 1. Hexadecimal (base 16) uses 0 through 9 plus A through F. Because 16 is exactly 24, every group of four binary digits maps to one hex digit. To convert, pad the binary string on the left with zeros until its length is a multiple of four, then replace each nibble.
For example, the binary string 10101111 splits into 1010 and 1111. The first group equals 10 in decimal, which is A in hex. The second equals 15, which is F. So the result is AF.
The reverse process expands each hex character into exactly four bits. The hex value 3B becomes 0011 for the 3 and 1011 for the B, yielding 00111011. Leading zeros are stripped at the end unless the entire number is zero, leaving 111011.
Nibble reference table
Use this table to look up any four-bit group when converting by hand. Memorizing these sixteen patterns makes reading memory dumps much faster.
| Binary | Hex | Decimal |
|---|---|---|
| 0000 | 0 | 0 |
| 0001 | 1 | 1 |
| 0010 | 2 | 2 |
| 0011 | 3 | 3 |
| 0100 | 4 | 4 |
| 0101 | 5 | 5 |
| 0110 | 6 | 6 |
| 0111 | 7 | 7 |
| 1000 | 8 | 8 |
| 1001 | 9 | 9 |
| 1010 | A | 10 |
| 1011 | B | 11 |
| 1100 | C | 12 |
| 1101 | D | 13 |
| 1110 | E | 14 |
| 1111 | F | 15 |
Common use cases for hex and binary
Developers encounter both bases constantly. IPv4 addresses are often written in dotted decimal but stored as 32-bit binary values; converting them to hex makes subnet masks easier to read. For instance, 11000000101010000000000100000001 becomes C0A80101.
CSS color codes are another everyday example. The hex triplet #FF5733 represents red 255, green 87, blue 51. In binary that is 11111111 01010111 00110011. When debugging memory dumps or working with low-level protocols, switching between these representations quickly is essential. Hardware engineers also rely on hex to configure registers where each bit controls a specific flag.
Handling large values and edge cases
This binary to hex converter handles arbitrarily long strings because it processes the input character by character rather than parsing it as a single integer. That means a 256-bit hash or a 2048-bit RSA key converts without overflow errors. JavaScript numbers lose precision beyond 53 bits, so string manipulation is the only safe approach for cryptographic data.
Leading zeros are preserved during hex-to-binary conversion: each hex digit always expands to exactly four bits. However, when converting binary to hex, leading zeros beyond the final nibble boundary are dropped so the output stays clean. An input of all zeros returns a single 0. If you need fixed-width output, pad the result manually to the desired byte length.
Worked examples
Each result below was produced by the same code the tool runs, so you can check your own numbers against them.
| Example | Input | Result |
|---|---|---|
| Byte 10101111 | Input value: 10101111; Conversion direction: bin2hex | Hexadecimal: AF |
| Hex FF to binary | Input value: FF; Conversion direction: hex2bin | Binary: 11111111 |
| 32-bit address | Input value: 11000000101010000000000100000001; Conversion direction: bin2hex | Hexadecimal: C0A80101 |
| Zero | Input value: 0; Conversion direction: bin2hex | Hexadecimal: 0 |
FAQ
Why do we group binary digits in fours for hex?
Hexadecimal is base 16, and 16 equals 2 raised to the fourth power. Therefore exactly four binary digits (one nibble) represent every possible hex digit from 0 to F.
Does this tool support the 0x prefix?
Yes. You can include or omit the 0x or 0X prefix when entering hexadecimal values. The converter strips it before processing.
Can I convert negative numbers?
This tool handles unsigned bit strings. For signed integers, convert the two's complement binary representation directly, and the hex output will reflect those bits.
Is there a limit on input length?
No. The converter processes the string sequentially, so it handles values from a single bit up to thousands of digits without precision loss.
Are spaces allowed in the input?
Spaces are stripped automatically. You can paste formatted strings like 1010 1111 or C0 A8 01 01 and they will be parsed correctly.
What happens if I enter invalid characters?
The converter shows an error message. Binary mode accepts only 0 and 1, while hex mode accepts 0 through 9 and A through F.