Decimal to Hex Converter - Number to Hexadecimal
—————Convert Decimal Numbers to Hex
Type a whole number and the hexadecimal result appears immediately in upper case, along with binary and octal. Turn on grouping to split long hex strings into blocks of four digits (two bytes). Values beyond 253, where most calculators start rounding, convert exactly.
The Divide-by-16 Method
Divide the number by 16, keep the remainder as one hex digit, and repeat with the quotient until it reaches zero. Remainders of 10 to 15 are written A to F. The first remainder you get is the rightmost digit.
Worked example: 48879
| Number | ÷ 16 | Remainder | Hex digit |
|---|---|---|---|
| 48879 | 3054 | 15 | F |
| 3054 | 190 | 14 | E |
| 190 | 11 | 14 | E |
| 11 | 0 | 11 | B |
Reading the digits from the bottom up gives BEEF, so 48879 = 0xBEEF. Check: 11 × 4096 + 14 × 256 + 14 × 16 + 15 = 48879.
If you already know the binary form, there is a shortcut: split the bits into groups of four from the right and replace each group with one hex digit.
Powers of 16
| Power | Decimal | Hex |
|---|---|---|
| 160 | 1 | 1 |
| 161 | 16 | 10 |
| 162 | 256 | 100 |
| 163 | 4,096 | 1000 |
| 164 | 65,536 | 10000 |
| 165 | 1,048,576 | 100000 |
| 166 | 16,777,216 | 1000000 |
| 167 | 268,435,456 | 10000000 |
| 168 | 4,294,967,296 | 100000000 |
Common Decimal to Hex Conversions
| Decimal | Hex |
|---|---|
| 10 | A |
| 15 | F |
| 16 | 10 |
| 32 | 20 |
| 64 | 40 |
| 100 | 64 |
| 127 | 7F |
| 128 | 80 |
| 200 | C8 |
| 255 | FF |
| 256 | 100 |
| 500 | 1F4 |
| 1,000 | 3E8 |
| 1,024 | 400 |
| 4,096 | 1000 |
| 10,000 | 2710 |
| 65,535 | FFFF |
| 1,000,000 | F4240 |
| 16,777,215 | FFFFFF |
Example: RGB to a Hex Colour
Web colours are three bytes written as hex: red, green and blue. To
turn rgb(70, 130, 180) into a hex code, convert each value
on its own and pad to two digits:
- 70 ÷ 16 = 4 r 6, so red is
46. - 130 ÷ 16 = 8 r 2, so green is
82. - 180 ÷ 16 = 11 (B) r 4, so blue is
B4.
Joined together that is #4682B4, the CSS colour
"steelblue". Values below 16 need a leading zero: 9 becomes
09, not 9.
Typical Uses
Decimal to hex comes up when writing colour codes from RGB values, setting register or flag values in firmware, building byte sequences for protocols, and reading Unicode code points. For the reverse direction, use hex to decimal; to convert between other bases, use the number base converter.
Related Tools
JWT Decoder
Decode JSON Web Tokens and inspect header, payload and signature.
Base64 Encode / Decode
Encode text to Base64 or decode Base64 strings back to plain text.
URL Encode / Decode
Percent-encode or decode URLs and query-string parameters safely.
Hash Generator
Generate MD5, SHA-1, SHA-256, SHA-384, and SHA-512 hashes from text.