Hex to Decimal Converter
Converts hexadecimal to decimal and back, with binary and octal alongside.
Last updated
Your details
Result
- Binary (base 2)
- 11111111
- Decimal (base 10)
- 255
- Hexadecimal (base 16)
- FF
- Octal (base 8)
- 377
- Bits needed
- 8
2 hex digits
FF in base 16…
value = Σ digit × baseᵖᵒˢⁱᵗⁱᵒⁿ
2 digits, read right to left
Each position is worth 16 times the one to its right
Total in decimal: 255
255
Formula — written step by step
Hexadecimal FF…
value = Σ digit × 16ᵖᵒˢⁱᵗⁱᵒⁿ
F = 15 in decimal
Left F: 15 × 16¹ = 240
Right F: 15 × 16⁰ = 15
240 + 15
FF = 255
Hexadecimal uses sixteen digits, so A to F stand for 10 to 15. Each position to the left is worth sixteen times the one before it, exactly as each decimal position is worth ten times the one before.
A worked example
Reading a colour code
- CSS colour
- #3A7BD5
- Channels
- red 3A, green 7B, blue D5
- 3A = 3×16 + 10 = 58
- 7B = 7×16 + 11 = 123
- D5 = 13×16 + 5 = 213
- Each channel runs 00 to FF, or 0 to 255
rgb(58, 123, 213)
Two hex digits cover exactly 0 to 255, which is one byte — the range of a single colour channel. That is why colour codes are six hex digits rather than some other length: three channels of one byte each.
How to use this calculator
- Enter a hexadecimal value. A leading 0x is accepted and ignored, and case does not matter.
- Read the decimal equivalent, with binary and octal shown alongside.
- Switch the mode to convert a decimal number into hexadecimal.
- Very long values are handled exactly — the conversion uses arbitrary-precision integers rather than floating point.
Counting in sixteens
Hexadecimal is base sixteen. It needs sixteen digits, so after 0 to 9 it borrows the letters A to F for the values 10 to 15. Each position is worth sixteen times the one to its right, so FF is 15 × 16 + 15 = 255.
The conversion to decimal is the same positional arithmetic used for any base: multiply each digit by the base raised to its position, counting from zero on the right, and add the results.
Why computing uses hex
Sixteen is two to the fourth power, so one hex digit corresponds to exactly four binary digits — a nibble — with no remainder. That makes converting between hex and binary a lookup rather than a calculation, and it means a byte is always precisely two hex digits.
This is why memory addresses, colour codes, MAC addresses and hashes are all written in hex. It is four times more compact than binary and maps onto it perfectly, which decimal does not: 10 is not a power of 2, so decimal digits do not align with bit boundaries at all.
Notation and where you will meet it
A leading 0x marks a hexadecimal literal in C, JavaScript, Python and most of their descendants. HTML and CSS use a leading hash for colours, assembly languages often use a trailing h, and some contexts use no marker at all and rely on context.
The values themselves are the same regardless. This converter accepts a leading 0x or none, and treats upper and lower case alike — FF, ff and 0xFF are all 255.
Hex digits and their values
| Hex | Decimal | Binary | Hex | Decimal | Binary |
|---|---|---|---|---|---|
| 0 | 0 | 0000 | 8 | 8 | 1000 |
| 1 | 1 | 0001 | 9 | 9 | 1001 |
| 2 | 2 | 0010 | A | 10 | 1010 |
| 3 | 3 | 0011 | B | 11 | 1011 |
| 4 | 4 | 0100 | C | 12 | 1100 |
| 5 | 5 | 0101 | D | 13 | 1101 |
| 6 | 6 | 0110 | E | 14 | 1110 |
| 7 | 7 | 0111 | F | 15 | 1111 |
Every hex digit maps to exactly four binary digits, which is the whole reason hexadecimal is used in computing: it is a compact way of writing binary that converts without arithmetic.
Frequently asked questions
Why does hex use letters?
Because base sixteen needs sixteen distinct digits and the decimal system only supplies ten. A to F fill in for the values 10 to 15.
What is 0x?
A prefix marking a hexadecimal literal in most programming languages. It carries no value — 0xFF is simply FF, or 255.
Does case matter?
No. FF and ff are identical. Upper case is the more common convention in colour codes and hashes.
Why are colour codes six hex digits?
Two digits per channel, covering 0 to 255, for red, green and blue. Two hex digits are exactly one byte.