Hex to decimal converter
Type a hexadecimal number to get its decimal value, or switch direction for decimal to hex. Every conversion shows its working: place values one way, repeated division by 16 the other.
Digits 0 to 9 and A to F, upper or lower case. A leading 0x, # or $ is ignored, and so are spaces.
Working: each digit times its place value
| Digit | Value | Place | Place value | Digit × place |
|---|---|---|---|---|
| B | 11 | 16³ | 4,096 | 45,056 |
| E | 14 | 16² | 256 | 3,584 |
| E | 14 | 16¹ | 16 | 224 |
| F | 15 | 16⁰ | 1 | 15 |
| Sum | 48,879 | |||
11×16³ + 14×16² + 14×16¹ + 15×16⁰
= 45,056 + 3,584 + 224 + 15
= 48,879
What hexadecimal is
Hexadecimal, or hex, is base 16. Decimal runs out of digits at 9 and carries into the tens column; hex keeps going with six letters, A to F for ten to fifteen, and only carries at sixteen. So 10 in hex is sixteen, 100 is 16 × 16 = 256, and FF is the largest two digit value, 255.
| 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 |
Hex to decimal chart: 00 to FF
Every one-byte value. Find the first hex digit down the side and the second along the top: 7F is row 7, column F, which is 127. The top row is 0 to 15, and each row down adds 16.
| First digit | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | A | B | C | D | E | F |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
| 1 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 |
| 2 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 |
| 3 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 |
| 4 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 |
| 5 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 |
| 6 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 |
| 7 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 |
| 8 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 |
| 9 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 |
| A | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 |
| B | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 |
| C | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 |
| D | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 |
| E | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 |
| F | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 |
The same bytes as characters are in the ASCII table, and a byte read as a signed number (80 to FF as −128 to −1) is covered by two's complement.
Printable hex to decimal chart
The same 00 to FF grid as one black-on-white image, for printing or a slide.
Click to download: Hex to decimal chart
Why programmers use hex
- Four bits per digit. Sixteen is 24, so each hex digit is exactly one group of four bits, a nibble. Converting to binary is a lookup, digit by digit, with no arithmetic; the hex to binary converter shows it.
- A byte is two digits. Eight bits always fit in 00 to FF, so memory dumps, network packets and file formats line up in neat pairs. The same byte in decimal takes one to three digits and does not line up.
- Colours. A CSS colour such as #1E90FF is three bytes: red 1E = 30, green 90 = 144 and blue FF = 255.
- Memory addresses and masks. An address like 0x7FFF0010 or a mask like 0xFF00 is easier to read and check in hex, because you can see which bits are set without converting anything.
Worked examples
1A3 to decimal
1×16² + A×16¹ + 3×16⁰
= 1×256 + 10×16 + 3×1
= 256 + 160 + 3
= 419
A is 10, so the middle digit is worth 10 × 16. Try it
1000 to hex
1000 ÷ 16 = 62 remainder 8
62 ÷ 16 = 3 remainder 14 (E)
3 ÷ 16 = 0 remainder 3
Read the remainders upwards: 3E8. Try it
Powers of 16 are the place values, the way powers of 10 are in decimal. The first few are worth knowing:
| Power | Value | In hex |
|---|---|---|
| 16⁰ | 1 | 1 |
| 16¹ | 16 | 10 |
| 16² | 256 | 100 |
| 16³ | 4,096 | 1000 |
| 16⁴ | 65,536 | 10000 |
| 16⁵ | 1,048,576 | 100000 |
| 16⁶ | 16,777,216 | 1000000 |
| 16⁷ | 268,435,456 | 10000000 |
| 16⁸ | 4,294,967,296 | 100000000 |
To add, subtract or multiply hex numbers directly, with carries shown, use the hex calculator. For signed values in a fixed number of bits, see two's complement and the binary converter.
Questions
What is FF in decimal?
FF is 255. The left F is worth 15 × 16 = 240 and the right F is worth 15 × 1 = 15, and 240 + 15 = 255. It is the largest value one byte can hold, which is why it turns up in colour codes and masks.
How do I convert hex to decimal by hand?
Number the digits from the right starting at 0. Multiply each digit by 16 to the power of its position, using A = 10, B = 11, C = 12, D = 13, E = 14 and F = 15, then add the results. For 1A3 that is 1×256 + 10×16 + 3×1 = 419.
How do I convert decimal to hex?
Divide the number by 16 and write down the remainder, then divide the quotient by 16 again, and keep going until the quotient is 0. Write each remainder as a hex digit (10 is A, 15 is F) and read them from the last one to the first. 1000 gives remainders 8, 14 and 3, so it is 3E8.
What does 0x mean in front of a number?
It marks the number as hexadecimal in C, JavaScript, Python and most other languages, so 0x10 is sixteen and not ten. CSS writes a # instead for colours, and some assemblers use a trailing h or a leading $. The converter accepts 0x, # and $ and ignores them.
How big a number can this convert?
Up to 64 digits of either base, which is 256 bits in hex. The arithmetic uses whole numbers of any size, so nothing is rounded the way it would be in a spreadsheet past about 15 digits. Negative numbers and fractions are not converted here; a negative number needs a fixed width, which the two's complement page covers.
Why is hexadecimal base 16?
Because 16 is 2 to the power 4, so one hex digit stands for exactly four bits. That makes converting between hex and binary a matter of looking up each digit, while still writing a byte in two characters instead of eight.