Hexadecimal Explained — What Hex Is and Why Developers Use It
Hexadecimal — base-16 — is the number system developers encounter most frequently outside of decimal. It appears in colour codes, memory addresses, cryptographic hashes, error codes, network MAC addresses, Unicode code points, and anywhere that binary data needs to be represented compactly for human reading. Once you understand why hex exists and how it works, you will find it straightforward to read and write.
Convert hex to decimal, binary, octal, and ASCII instantly with our free Hex Converter tool. For colour values specifically, our Color Converter converts hex colours to RGB, HSL, and other formats in one step.
What Makes Hex Special for Computing
Hexadecimal is base-16, using the 16 digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F. Here A equals 10, B equals 11, C equals 12, D equals 13, E equals 14, and F equals 15 in decimal.
The property that makes hex so valuable in computing: one hex digit represents exactly 4 bits (a nibble). Two hex digits represent exactly 8 bits (one byte). This creates a clean, predictable mapping between hex and binary that decimal does not have.
Compare representing the byte value 181 in three ways: Binary: 10110101 — eight characters, hard to read, easy to miscount Decimal: 181 — three characters, readable, but no relationship to bit structure Hexadecimal: B5 — two characters, where B maps to 1011 and 5 maps to 0101 in binary
A 64-bit memory address in binary would be 64 characters. In hex it is 16 characters. In decimal it can be up to 20 characters with no clear byte boundaries. For anything where bit-level structure matters, hex is clearly superior.
Converting Hex to Other Bases
Hex to Decimal
Each position in hex represents a power of 16, just as decimal positions represent powers of 10.
B5 in hex equals: B times 16 plus 5 times 1 = 11 times 16 plus 5 = 176 plus 5 = 181. 3F2A in hex equals: 3 times 4096 plus F times 256 plus 2 times 16 plus A times 1 = 12288 plus 3840 plus 32 plus 10 = 16170.
Hex to Binary (The Fast Way)
Convert each hex digit independently to its 4-bit binary equivalent: B = 1011, 5 = 0101 B5 in hex = 10110101 in binary
The reverse is equally fast: group binary digits in sets of 4 from the right and convert each group to one hex digit. 10110101 becomes 1011|0101 = B|5 = B5. This direct mapping is the reason hex is universally preferred over decimal for representing binary data.
Hex in Code
JavaScript: parseInt("B5", 16) converts hex string to decimal number (181). (181).toString(16) converts decimal to hex string ("b5"). Python: int("B5", 16) gives 181. hex(181) gives "0xb5". format(181, "x") gives "b5" without prefix. C and C++: 0xB5 is a hex literal in source code, equal to 181. CSS: hex colours use the hash prefix: #f58220.
Convert any hex value to decimal, binary, octal and ASCII — free and instant
Try Hex Converter Free →Where You Will See Hex in Development
CSS colour codes: #f58220 represents three bytes — F5 (red channel 245), 82 (green channel 130), 20 (blue channel 32). Convert and explore colours with our Color Converter.
Memory addresses: 0x00007fff5fbff820 is a 64-bit memory address in hex. These appear in debuggers, crash reports, and security research.
Windows error codes: 0x80070057 is a well-known Windows error (ERROR_INVALID_PARAMETER). Microsoft error codes are always displayed in hex.
Cryptographic hashes: a SHA-256 hash like d8e8fca2dc0f896fd7cb4cb0031ba249 is 256 bits represented as 64 hex characters. Each pair of hex characters is one byte of the hash output.
MAC addresses: 00:1B:63:84:45:E6 — six bytes separated by colons, each byte shown as two hex digits. This identifies your network interface card uniquely on local networks.
IPv6 addresses: 2001:0db8:85a3:0000:0000:8a2e:0370:7334 — eight groups of four hex digits, each group representing 16 bits. Check IP information with our IP Lookup tool.
Unicode code points: U+1F600 is the code point for the grinning face emoji in hex. U+0041 is the code point for the letter A. Our ASCII Converter shows the relationship between characters and their numeric values.

