Home / Learn / What Is Hexadecimal?

What Is Hexadecimal?

Hexadecimal is base 16 — the compact shorthand developers use instead of long binary strings. If you've ever seen a color like #FF5733 or an error like 0x80070005, you've already met it.

Sixteen digits, including letters

Hexadecimal ("hex" for short) is the base-16 positional number system. Sixteen needs sixteen distinct digit symbols, so after 0–9 it borrows the letters A–F for the values 10–15:

Hex01234567
Decimal01234567
Hex89ABCDEF
Decimal89101112131415

The letters aren't mysterious — they're just single-character symbols for "ten" through "fifteen", so each hex digit still occupies one character. Case doesn't matter: ff and FF are the same value.

Why hex exists: binary is unreadable

The magic property: one hex digit = exactly four bits (a nibble), because 16 = 2⁴. So an 8-bit byte is always exactly two hex digits:

BinaryHexDecimal
0000 0000000
0010 11012D45
1111 1111FF255
1010 0101A5165

FF is infinitely easier to read, say and remember than 11111111 — and converting between them is trivial (see our binary vs hexadecimal guide). That's the whole reason hex exists: it's binary, made human-friendly.

Reading hex values

Place value works as always — columns are powers of 16 (1, 16, 256, 4096…). Take 2D:

2 × 16 + 13 × 1 = 32 + 13 = 45. And FF = 15 × 16 + 15 = 255 — the largest single byte, matching binary 11111111 exactly. One more, with three digits: 1A3 = 1 × 256 + 10 × 16 + 3 = 256 + 160 + 3 = 419.

You'll often see hex with a 0x prefix — 0x2D — which is just the standard way programming languages say "this number is hexadecimal". It dates back to C and is now used in Python, JavaScript, Java and many others.

Where you'll meet hex in the wild

Notice the pattern: hex shows up wherever humans need to look at raw bytes. It's the display language of low-level computing. If you open any file in a hex editor, you'll see exactly this: the file's bytes laid out as two-digit hex values, sixteen per row, with the text interpretation alongside. Forensics analysts, reverse engineers and the merely curious all read files this way — hex is the closest a human gets to seeing what the machine sees.

Try it yourself

Convert hex values to decimal and binary, and decode color codes into their red, green and blue channels.

Key takeaways

Frequently asked questions

Why does hexadecimal use letters A to F?

Base 16 needs sixteen distinct digits. After 0–9 run out, the letters A–F stand in for values 10–15, so each hex digit still fits in a single character.

What does 0x mean in front of a number?

0x is the standard prefix marking a number as hexadecimal, used in C, Python, JavaScript and many other languages. 0x2D means the hex value 2D, which is 45 in decimal.

Why do programmers prefer hex over binary?

Compactness. One hex digit represents exactly four bits, so 8 bits fit in two hex digits. FF is far easier to read, write and remember than 11111111.

How do I convert hex to binary?

Replace each hex digit with its 4-bit binary equivalent: 0→0000, 1→0001 … 9→1001, A→1010, B→1011, C→1100, D→1101, E→1110, F→1111. So 2D becomes 0010 1101.