What is Hexadecimal to Binary Converter?
hex to binary, hexadecimal color codes This tool runs entirely in your browser. No data is sent to any server, and no signup is needed.
Hexadecimal to Binary Converter
Convert hex to binary. Each hex digit = 4 binary digits. Useful for low-level programming, color codes, and byte manipulation.
About
Hexadecimal to binary conversion expresses a base-16 number as a base-2 number by mapping each hex digit to exactly four binary digits (one nibble). Because 16 = 2^4, the mapping is lossless, position-preserving, and instantaneous to do by lookup.
Hex is the standard short notation in CSS color codes, MAC addresses, IPv6 addresses, hash digests (SHA-256, MD5), machine-code dumps, x86 assembly literals, and most binary file formats inspected by tools like xxd, hexdump, and Wireshark. Converting to binary is how you see the actual bits, which matters whenever a single bit drives behaviour (a CPU flag register, a permission bit field, an embedded memory-mapped register).
How it works
Hex uses digits 0 to 9 then A to F to represent values 10 to 15. Each digit covers a four-bit group, so a hex literal like 0xF3 becomes binary 1111 0011 (one nibble of 1s, one nibble of 0011 = 3).
Hex 0 1 2 3 4 5 6 7 8 9 A B C D E F
Bin 0000 0001 0010 0011 0100 0101 0110 0111
1000 1001 1010 1011 1100 1101 1110 1111
0xFF -> 1111 1111 (255 dec, one byte)
0xF3A5 -> 1111 0011 1010 0101 (62,373 dec, two bytes)
Algorithm: substitute each hex digit with its 4-bit pattern.
The reverse (binary to hex) groups bits in fours from the right and substitutes back. Because 4 bits per hex digit divides cleanly, no padding or carrying is needed for unsigned values.
Worked example
Convert the CSS color #1E88E5 (Material Design blue 600) into binary, byte by byte.
- Input: 1E 88 E5 (three byte pairs, RGB order).
- Map digit 1: 0001. Digit E: 1110. Byte 1 = 0001 1110.
- Map digit 8: 1000. Digit 8: 1000. Byte 2 = 1000 1000.
- Map digit E: 1110. Digit 5: 0101. Byte 3 = 1110 0101.
- Concatenate: 00011110 10001000 11100101.
- Decode RGB: Red 30, Green 136, Blue 229.
Reference table
| Hex | Binary (4 bits) | Decimal | Use |
|---|---|---|---|
| 0 | 0000 | 0 | Null nibble, padding |
| 1 | 0001 | 1 | Least-significant bit |
| 4 | 0100 | 4 | Single bit set |
| 8 | 1000 | 8 | Most-significant bit of a nibble |
| 9 | 1001 | 9 | Last decimal digit |
| A | 1010 | 10 | First extended digit |
| F | 1111 | 15 | All bits set |
| FF | 1111 1111 | 255 | One byte saturated |
| FFFF | 1111 1111 1111 1111 | 65,535 | Two-byte saturated (uint16 max) |
| FFFFFFFF | 32 ones | 4,294,967,295 | uint32 max |
| DEADBEEF | 1101 1110 1010 1101 1011 1110 1110 1111 | 3,735,928,559 | Common debug sentinel |
Common pitfalls
- Leading zeros dropped. 0x3 in binary is 0011, not 11. Pad each hex digit to its full four bits, or the byte boundary shifts.
- Mixing letter case. Hex F and f are the same digit; 0xfF and 0xFF are equal. Choose one style (most languages emit lower-case) for readability.
- Forgetting the 0x prefix in code. In C/JS, the literal FF without a prefix is the variable named FF, not 0xFF. Use 0xFF (or 0x ff in Python) explicitly.
- Confusing signed and unsigned. 0xFF as an 8-bit signed byte is -1, not 255. Two's-complement applies to fixed-width signed types; the bit pattern is the same.
- Color-code byte order. CSS is RGB; some Windows APIs and Microsoft Office store COLORREF as BGR (0x00BBGGRR), so #1E88E5 in CSS is 0xE5881E in those APIs.
- Word-size sign extension. Converting 0xFF to a 32-bit integer pads with zeros if unsigned, ones if sign-extended from int8.
- Endianness in memory dumps. The value 0x12345678 stored in little-endian memory is the byte sequence 78 56 34 12. A binary dump that reads bytes in memory order shows the reversed bit pattern. Always check whether your tool reads logical or memory order before drawing conclusions about bits.
Related tools and glossary
Frequently asked questions
Why is hex used for color codes?
A 6-digit hex code encodes RGB as three byte pairs: RR GG BB. #FF00FF is full red (255), no green (0), full blue (255) = magenta. Hex makes byte boundaries visually obvious, which is why CSS, Photoshop, and Figma use it for color picking.
How do I convert one hex digit to 4 bits manually?
Memorise the 16-row lookup: 0 = 0000, 1 = 0001, 2 = 0010, 3 = 0011, 4 = 0100, 5 = 0101, 6 = 0110, 7 = 0111, 8 = 1000, 9 = 1001, A = 1010, B = 1011, C = 1100, D = 1101, E = 1110, F = 1111. Then concatenate the 4-bit groups.
What does the 0x prefix mean?
0x is the standard literal prefix for hexadecimal in C, C++, Python, Java, JavaScript, Rust, and most modern languages, originally introduced in B (1969) and standardised by C. 0xFF = 255 decimal = 11111111 binary. Some assemblers use a trailing h instead (FFh).
Why do programmers prefer hex over raw binary?
Hex is exactly four times denser than binary. A 32-bit integer is 32 characters in binary, 8 in hex, 10 in decimal. Hex preserves byte and nibble boundaries (each pair is one byte, each digit one nibble), so memory dumps, color codes, and machine code are easier to read than decimal but more compact than binary.
How does this differ from a base64 or ASCII encoding?
Hex is a literal base-16 representation of the underlying bits, so it round-trips losslessly with binary. Base64 packs 3 bytes into 4 printable characters (33 percent overhead, alphabet A-Z a-z 0-9 + /). ASCII represents each character as one byte but is not a numeric base. Use hex when you need to inspect bits; use base64 when you need to embed binary data inside text protocols like email and JSON.
Sources
- ISO/IEC 9899:2018 (C18), section 6.4.4.1 Integer constants (hexadecimal-constant syntax).
- W3C CSS Color Module Level 4, section 5.1, hexadecimal notation.
- Knuth D.E., The Art of Computer Programming, Vol. 2, section 4.1 (positional number systems).
- Patterson D.A. and Hennessy J.L., Computer Organization and Design, 6th ed., chapter 2.
