Hexadecimal (hex) is a base-16 number system that uses sixteen symbols: digits 0-9 representing values zero through nine, and letters A-F representing values ten through fifteen. It’s the standard notation for representing binary data in a human-readable form.
Why hex exists in computing
One hex digit maps perfectly to 4 binary bits (a nibble). Two hex digits represent one byte (8 bits). This makes hex far more compact and readable than binary while maintaining a direct conversion path.
Binary: 11111111
Decimal: 255
Hexadecimal: FF
Writing FF is much easier than writing 11111111, and converting between hex and binary is trivial — each hex digit maps to exactly 4 bits.
Common uses
Colors: CSS hex colors use 6 hex digits (3 bytes) for RGB values. #FF6B35 means red=255, green=107, blue=53. The shorthand #F63 expands to #FF6633.
Memory addresses: Debuggers and system programming use hex for memory addresses: 0x7FFE1234ABCD. The 0x prefix is the standard notation to indicate a hex value in most programming languages.
MAC addresses: Network interface identifiers use hex pairs separated by colons: 00:1A:2B:3C:4D:5E.
Hash digests: MD5, SHA-256, and other hash functions output their results as hex strings. An MD5 hash is 32 hex characters (16 bytes).
Character encoding: Unicode code points are written in hex: U+0041 is the letter “A”. Hex escape sequences in strings (\x41, \u0041) represent characters by their code point.
Hex in programming
Most languages support hex literals with the 0x prefix:
const red = 0xFF; // 255
const mask = 0xFF00; // 65280
const flags = 0x0F & value; // bitwise AND with 00001111
Hex is particularly useful for bitwise operations, hardware register manipulation, and reading binary file formats.
Converting hex
Hex to decimal: multiply each digit by its positional power of 16. 2F = (2 × 16) + (15 × 1) = 47.
Decimal to hex: repeatedly divide by 16, collecting remainders. 255 ÷ 16 = 15 remainder 15 → FF.
Convert between hex and text with Hex to Text and ASCII to Hex. For hex arithmetic, use the Hex Calculator. Convert between number bases with the Number Base Converter.