Why hex exists at all
Computers think in binary. A byte is eight bits, and eight bits is a clumsy number to write out — a single byte like 10110110 is already hard to parse at a glance, and a 32-bit register value is nearly unreadable. Hexadecimal (base 16) compresses the same data into half the length without losing any of the information.
The trick is that 16 is exactly 2⁴, so every hex digit maps cleanly to 4 bits. The byte above splits into 1011 0110, which is B and 6 — a two-character hex representation (B6) for eight bits. Once you know that A=10, F=15, you can read or write binary in your head.
That's why hex shows up everywhere programmers touch raw bytes: memory addresses, machine code, network protocols, file headers, crypto hashes, MAC addresses, and color codes. Hex is the shortest human-friendly way to write "exactly these bits".
The math: converting hex to decimal by hand
Each hex digit is worth 16 times the digit to its right, the same way each decimal digit is worth 10 times the one to its right. To convert 2F:
- The
Fis in the ones place, worth 15 × 1 = 15. - The
2is in the sixteens place, worth 2 × 16 = 32. - Total: 32 + 15 = 47.
For larger values the pattern extends — a four-digit hex like 1A2B has places worth 4096, 256, 16, and 1. You almost never do it by hand past a single byte, which is exactly what the converter is for. But understanding the principle helps you read hex without translating every time.
A handful of round values are worth memorizing: 0xFF = 255 (max byte), 0x80 = 128 (high bit set), 0x20 = 32 (space in ASCII), 0xFFFF = 65535 (max 16-bit value), 0xDEADBEEF = a very famous debug marker.
Hex in the wild — where you'll actually see it
- CSS colors.
#FF5733is three bytes — red, green, blue — each a 0-255 intensity. Our Color Converter handles the full pipeline between hex, RGB, and HSL. - Memory addresses. A debugger or crash log that prints
0x00007ffee...is pointing at a 64-bit pointer. Addresses are always hex in system software because byte boundaries matter. - Error codes. Windows error codes, HRESULT values, and kernel panics print in hex so bit flags can be spotted at a glance.
0x80070005has meaning in the high and low halves that would be invisible in decimal. - Crypto hashes. SHA-256 outputs are always printed as 64 hex characters. Our Hash Generator emits them the same way.
- MAC addresses and UUIDs. Ethernet MACs (
aa:bb:cc:dd:ee:ff) are six bytes in hex; UUIDs are 16 bytes formatted with hyphens.
Prefix conventions: 0x, #, and nothing
Hex values are usually written with a prefix that tells you the base. Different contexts use different prefixes:
0x— C, C++, Java, JavaScript, Python, Go, Rust, and basically every modern language. This is the most common prefix in code.#— CSS color codes and some config files. Not legal in code.$— assembly, old Pascal dialects, 6502 and 68000 assembler. Rare outside retro computing.- No prefix — hexdump, many command-line tools, HTTP status-code tables. Only works when the context tells you it's hex.
This converter accepts any of those — 0xFF, #FF, and FF all produce 255. Case doesn't matter either. If you need a different base entirely, use our Number Base Converter for arbitrary bases 2-36.
Related conversion tools on CodeBoxTools
- Binary to Decimal — the same idea for base 2, with support for fixed bit widths and two's complement.
- Number Base Converter — arbitrary bases from 2 to 36, including octal and base-36 short IDs.
- Color Converter — HEX, RGB, HSL, HSV all at once when you're working with hex color codes.
- Hash Generator — produces SHA-256, SHA-1, and other hashes as hex strings.