Skip to the tool
Binary Translator Free tools

What is hexadecimal?

Hexadecimal, or hex, is the base-16 number system. It uses the digits 0 to 9 and the letters A to F. Try a hex number in the box, then read on for how it works.

Updated · Written and checked by Murugan Vellaichamy

Waiting for input

Prefixes 0b, 0o, 0x and spaces or underscores between digits are fine. A point starts the fraction.

Result
Try:

The short answer

Hexadecimal counts in sixteens instead of tens. It needs sixteen digit symbols, so after 0 to 9 it uses A for 10, B for 11, up to F for 15. The next number after F is 10, which in hex means one sixteen and no ones.

Programmers use hex because one hex digit is exactly four bits. A byte, eight bits, is always two hex digits, from 00 to FF. That makes long binary numbers short and easy to read: 1111 1111 is just FF.

Hex chart: 0 to F

DecimalHexBinary
000000
110001
220010
330011
440100
550101
660110
770111
881000
991001
10A1010
11B1011
12C1100
13D1101
14E1110
15F1111

Place values in hex

Each place in a hex number is worth 16 times the place to its right: 1, 16, 256, 4096 and so on. To find the value, multiply each digit by its place value and add.

For 2AF: 2 × 256 = 512, A (10) × 16 = 160, and F (15) × 1 = 15. That adds up to 687. The hex to decimal converter shows this working for any number.

DigitPlace valueDigit × place value
2162 = 2562 × 256 = 512
A (10)161 = 1610 × 16 = 160
F (15)160 = 115 × 1 = 15

Counting in hex

Counting goes 0, 1 … 9, A, B, C, D, E, F, then 10. After 1F comes 20, after FF comes 100, and after FFF comes 1000. Each time a place passes F it goes back to 0 and carries 1 to the left, the same way 9 rolls over to 10 in decimal.

Why do programmers use hex?

Computers work in binary, but long strings of 0s and 1s are hard to read and easy to miscopy. Because 16 is 2 × 2 × 2 × 2, each hex digit stands for exactly one group of four bits, called a nibble.

You can turn binary into hex by grouping the bits in fours, and back again by writing each hex digit as four bits. Decimal has no shortcut like that.

Where do you see hexadecimal?

WhereExampleWhat it means
Web colours#FF8000Three bytes: red FF (255), green 80 (128), blue 00 (0)
Numbers in code0xFFThe 0x prefix marks a hex number in JavaScript and many other languages
Bytes in a file48 65 6C 6C 6FEach byte as two hex digits; these five spell “Hello” in ASCII
Character codes41The ASCII code for “A” (65 in decimal)

Converting hex

Sources and method

Conversions use exact whole-number arithmetic (JavaScript BigInt), so long numbers keep every digit. Fractions are kept as exact ratios; when the digits repeat, the repeating block is found and marked instead of rounded.

Questions

Why does hexadecimal use letters?

Base 16 needs sixteen single-digit symbols. The digits 0 to 9 give ten, so A to F stand for 10 to 15.

What does 0x mean in front of a number?

It marks the number as hexadecimal. In JavaScript, 0x is one of three prefixes, with 0b for binary and 0o for octal.

Is hex the same as base 16?

Yes. Hexadecimal, hex and base 16 all mean the same number system.

What is FF in decimal?

255: F (15) × 16 + F (15) = 240 + 15. It is the largest value one byte can hold.

More converters

Copied