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.

Frequently Asked Questions

The 0x prefix is a programming convention to distinguish hexadecimal literals from decimal numbers in source code. Without it, a value like 255 is ambiguous — is it the decimal number 255 or the hex number 255 (which would be 597 in decimal)? With 0xFF it is unambiguously the hexadecimal number FF, equal to decimal 255. Different contexts use different conventions: CSS uses the hash sign prefix for colours, programming languages use 0x, Unicode uses U+ prefix.
The hexadecimal equivalent of decimal 202 is CA. In hexadecimal, 202 is calculated as 12 × 16 + 10, where 12 is represented by C and 10 is represented by A.
A valid hexadecimal number uses digits 0–9 and letters A–F only. For example, 1A3F, FF, and CA are valid hexadecimal numbers.
The hexadecimal equivalent of decimal 254 is FE. In hexadecimal, 254 is calculated as 15 × 16 + 14, where 15 is F and 14 is E.
No. A through F and a through f represent exactly the same values. #F58220 and #f58220 are identical colours. 0xFF and 0xff are the same number. 0xDEADBEEF and 0xdeadbeef are the same 32-bit value. Convention varies by context — CSS colours are conventionally lowercase, Windows error codes are uppercase, cryptographic hash outputs are typically lowercase.
Every 4 bits require one hex digit. 8 bits (one byte) needs 2 hex digits. 16 bits needs 4 hex digits. 32 bits needs 8 hex digits. 64 bits needs 16 hex digits. 128 bits (for example a UUID or MD5 hash) needs 32 hex digits. This predictable relationship is why hex is preferred for representing fixed-width binary values — you always know exactly how many digits to expect based on the bit width.
Hex is just a way of writing numbers. Whether those numbers are signed or unsigned depends on the context and data type. In programming, a 32-bit signed integer stored in hex uses the two's complement representation — 0xFFFFFFFF represents -1 as a signed 32-bit integer, and 4,294,967,295 as an unsigned 32-bit integer. The same bits, different interpretations depending on whether you treat the type as signed or unsigned.
Scroll to Top
Checker Tools