Decimal to hex converter
Convert decimal numbers to hex — by repeated division by 16, every step shown. Exact at any size, with a worked example and a table of common values. Free, and computed in your browser.
Part of developer tools.
Binary
10101101
Octal
255
Decimal
173
Hexadecimal
AD
Decimal to hex table
| Decimal | Hex |
|---|---|
| 0 | 0 |
| 1 | 1 |
| 2 | 2 |
| 3 | 3 |
| 4 | 4 |
| 5 | 5 |
| 6 | 6 |
| 7 | 7 |
| 8 | 8 |
| 9 | 9 |
| 10 | A |
| 11 | B |
| 12 | C |
| 13 | D |
| 14 | E |
| 15 | F |
| 16 | 10 |
| 100 | 64 |
| 127 | 7F |
| 255 | FF |
| 256 | 100 |
| 1000 | 3E8 |
| 1024 | 400 |
| 4096 | 1000 |
| 65535 | FFFF |
| 4294967295 | FFFFFFFF |
| 18446744073709551615 | FFFFFFFFFFFFFFFF |
The last rows are the largest 32-bit and 64-bit unsigned values. The second is past the point where ordinary JavaScript numbers start rounding; the table and the converter above both compute with BigInt, so every digit is exact.
How to convert decimal to hex
Divide the decimal number by 16, write down the remainder, and repeat with the quotient until it reaches 0. The remainders, read from the last one back to the first, are the hex digits. For 173: 173 ÷ 16 = 10 remainder 13 (D); 10 ÷ 16 = 0 remainder 10 (A). Read upwards, that is AD. Remainders from 10 to 15 are written as the letters A to F — that is the only extra step compared with any other base.
Decimal and hex side by side
The largest 16-bit value is 65535 in decimal and FFFF in hex: 5 digits against 4. A decimal digit is worth log₂ 10 ≈ 3.32 bits, against 4 for a hex digit — not a whole ratio, so decimal and hex digits never line up and there is no digit-by-digit shortcut: the whole number has to be divided down, as above. Hex is the usual way to write bytes — colours like #FF8800, memory addresses, hashes, escape sequences — because a byte is always exactly two hex digits. In JavaScript and Python source, 173 is written 173 with no prefix in decimal and 0xAD in hex. Paste a prefixed number into the converter and it switches to the matching base; a number with no prefix is read in the selected base — decimal on this page.
Other conversions
Going the other way? Hex to decimal converter.
Or open the full number base converter and see a number in all four bases at once.