How to Convert Hexadecimal to Decimal
A hexadecimal number is a sum of powers of 16. To convert hex to decimal, multiply each digit by 16 raised to its position and add the results. This guide shows the hand method, a worked example, and the standard library calls that do it for you.
The positional method
Positions are numbered from the right starting at 0, and each position is worth 16 raised to that number:
- Replace letters with values: A=10, B=11, C=12, D=13, E=14, F=15.
- Multiply each digit by 16 raised to its position (rightmost digit is position 0).
- Add all the products together - the sum is the decimal value.
A quick example: FF
FF has two digits, both worth 15. The left F sits at position 1 (16¹ = 16) and the right F at position 0 (16⁰ = 1). So FF = 15×16 + 15×1 = 240 + 15 = 255 - the largest value one byte can hold.
The same expansion works for any length: 1A3 = 1×256 + 10×16 + 3×1 = 419.
Handling prefixes
You will meet hex written as FF, 0xFF, #FF, or &hFF depending on the language. The prefix is only notation - strip it before converting. Our converter accepts 0x and # prefixes automatically.
How 3e8 converts from hexadecimal to decimal
Multiply each digit by 16 raised to its position (starting at 0 from the right), then add the results:
Sum: 1000
Doing it in code
const hex = "ff";
const decimal = parseInt(hex, 16); // 255
// For large numbers, use BigInt:
const bigHex = "ffffffffffffffff";
const bigDecimal = BigInt("0x" + bigHex);Frequently Asked Questions
What is FF in decimal?
FF in hexadecimal is 255 in decimal: 15×16 + 15 = 255. It is the maximum value of one byte (8 bits) and of each RGB color channel.
How do letters work in hexadecimal?
Base 16 needs sixteen symbols but we only have ten digits, so A-F stand for 10-15. The letters carry no special meaning beyond their numeric value, and case does not matter.
How do I convert hex to decimal in my head?
For two-digit hex, multiply the first digit by 16 and add the second: 2A = 2×16 + 10 = 42. Knowing multiples of 16 up to 16×15 = 240 makes most byte values instant.