Base 16 → base 10
Hex to Decimal Converter
Turn a hexadecimal value into an ordinary decimal number — unsigned, or read as a signed integer at the width you choose.
—
—
How to convert hex to decimal
- Give every digit its place value. Counting from the right, positions are worth 160, 161, 162 and so on — 1, 16, 256, 4096, 65536.
- Replace any letter with its number: A is 10, B is 11, C is 12, D is 13, E is 14, F is 15.
- Multiply each digit by its place value.
- Add the products together. That total is the decimal value.
The formula
For a hex number with digits dn…d1d0, counting positions from zero at the right:
value = dₙ × 16ⁿ + … + d₂ × 16² + d₁ × 16¹ + d₀ × 16⁰
Nothing here is special to hex. It is the positional rule decimal already uses, with 16 in place of 10. Understand it once and you can convert from any base by hand.
Worked examples
2F
2 × 16 = 32
F × 1 = 15
----
47
1A2B
1 × 4096 = 4096
A × 256 = 2560
2 × 16 = 32
B × 1 = 11
------
6699
FFFF
F × 4096 = 61440
F × 256 = 3840
F × 16 = 240
F × 1 = 15
-------
65535
The last is worth remembering on its own. Four F digits is the largest value sixteen bits can hold without a sign, and it appears constantly as a mask or a sentinel.
Quick reference
The sixteen digits below cover every conversion on this page. For every byte from 00 to FF there is a full hex to decimal table.
| Hex | Decimal | Binary | Octal |
|---|---|---|---|
| 0 | 0 | 0000 | 0 |
| 1 | 1 | 0001 | 1 |
| 2 | 2 | 0010 | 2 |
| 3 | 3 | 0011 | 3 |
| 4 | 4 | 0100 | 4 |
| 5 | 5 | 0101 | 5 |
| 6 | 6 | 0110 | 6 |
| 7 | 7 | 0111 | 7 |
| 8 | 8 | 1000 | 10 |
| 9 | 9 | 1001 | 11 |
| A | 10 | 1010 | 12 |
| B | 11 | 1011 | 13 |
| C | 12 | 1100 | 14 |
| D | 13 | 1101 | 15 |
| E | 14 | 1110 | 16 |
| F | 15 | 1111 | 17 |
Prefixes: what 0x, #, $ and \x are telling you
Hex rarely appears bare. The marker in front of it is a claim about where the number came from, and recognising it saves you from converting the wrong thing.
0x2F— the C convention, inherited by C++, Java, Python, JavaScript, Go and Rust.#1A73E8— CSS and HTML color notation. Three bytes: red, green, blue.$2F— older assemblers, particularly 6502 and 68000 families.2Fh— the Intel assembler suffix. Same value, trailing marker.\x2F— a byte escape inside a string literal, not a standalone number.%2F— percent-encoding in a URL. This one is a forward slash.
Paste any of these above and the prefix is stripped before conversion.
Why FF matters more than 255 looks like it should
A byte is eight bits, and eight bits is two hex digits. That correspondence is why hex is everywhere in computing, and it turns certain values into landmarks.
| Hex | Decimal | What it marks |
|---|---|---|
| 00 | 0 | Empty byte; string terminator in C |
| 0F | 15 | Low nibble only — a common bit mask |
| 7F | 127 | Largest signed byte; last ASCII code point |
| 80 | 128 | Only the sign bit set |
| FF | 255 | Every bit set — a full byte, or −1 when signed |
| FFFF | 65,535 | A full 16-bit word |
Once FF reads as "one whole byte" rather than "two hundred and fifty-five", hex
dumps stop looking like noise. Byte boundaries are visible at a glance because they are always two
characters wide, which is precisely what decimal cannot give you.
Signed values and the width chips
Hex carries no sign of its own. FF is 255 if the surrounding code treats those
eight bits as unsigned and −1 if it treats them as a signed byte. The bits are identical;
only the interpretation differs.
That interpretation is two's complement: if the leftmost bit of the chosen width is 1, the value is negative, and you recover it by subtracting 2width. Use the chips above the input to switch readings.
FF as unsigned → 255 FF as int8 → 255 − 256 = −1 FF as int16 → 255 (the sign bit at position 15 is 0) 80 as unsigned → 128 80 as int8 → 128 − 256 = −128
If a debugger and your own arithmetic disagree about a value, this is almost always why.
To do this without a tool, work through the by-hand method, which has practice problems with answers. For when each notation is the right choice, see hex versus decimal.
Frequently asked questions
How do I convert hex to decimal by hand?
Multiply each digit by 16 raised to its position, counting from zero at the right, then add the products. For 2F that is 2 times 16 plus 15, which is 47.
What is FF in decimal?
255 read as unsigned, the largest value a single byte can hold. Read as a signed 8-bit integer the same bits mean -1.
What is 0x1A in decimal?
26. The 1 contributes 16 and the A contributes 10.
Can hex numbers be negative?
Hex notation has no sign. Negative values are represented by fixing a bit width and using two's complement, so the reading depends on how the surrounding code treats the bits.
Does the 0x prefix change the value?
No. It only signals that the digits are base 16. The converter removes it automatically.
Is there a limit on input length?
Not a practical one. Arbitrary-precision arithmetic means a 64-character hash converts exactly, with no overflow.