Decimal to Hex Converter
Type a whole number to see it in hex, worked out by dividing by 16 and turning the remainders 10–15 into A–F.
Decimal uses only the digits 0–9
In hex (base 16)
FF
Decimal 255 is FF in hex (base 16).
15×16 + 15 = 255
Tap a digit to step it up. Each tile is worth its digit × 16n.
How to convert decimal to hex
Divide the number by 16 and keep the remainder, a value from 0 to 15. Write remainders of 10 to 15 as the letters A to F. Keep dividing the quotient by 16 until it reaches 0, then read the remainders from last to first.
For 48,879: 48,879 ÷ 16 = 3,054 r 15 (F), 3,054 ÷ 16 = 190 r 14 (E), 190 ÷ 16 = 11 r 14 (E), 11 ÷ 16 = 0 r 11 (B). Reading upward gives BEEF, a value programmers like to use as a recognisable marker.
Another route is through binary: write the number in binary, then group the bits in fours from the right. Each group of four is one hex digit.
n = 16 × q + r, with r from 0 to 15 written 0–9, A–F
- Web colours are hex: #RRGGBB gives red, green and blue one byte each, 00 to FF (0 to 255), so 255 128 0 is #FF8000. Source: CSS Color Module Level 4, hex notation.
Round decimal numbers in hex
Decimal values that come up in code, colours and memory sizes, with their hex form.
| Decimal | Hex | Where you see it |
|---|---|---|
| 10 | A | |
| 15 | F | largest single hex digit |
| 16 | 10 | |
| 32 | 20 | ASCII space |
| 64 | 40 | |
| 100 | 64 | |
| 127 | 7F | largest signed byte |
| 128 | 80 | |
| 200 | C8 | |
| 255 | FF | largest byte, a full colour channel |
Show all 20 rowsShow fewer
| 256 | 100 | |
| 1,000 | 3E8 | |
| 1,024 | 400 | 1 KiB |
| 4,096 | 1000 | a common memory page (4 KiB) |
| 10,000 | 2710 | |
| 48,879 | BEEF | the BEEF marker |
| 65,535 | FFFF | largest 16-bit value, highest TCP port |
| 1,000,000 | F4240 | |
| 16,777,215 | FFFFFF | white, #FFFFFF |
| 4,294,967,295 | FFFFFFFF | largest 32-bit value |
Frequently Asked Questions
What is 255 in hex?
255 is FF: 255 ÷ 16 = 15 r 15, and 15 is F, so both digits are F. It is the largest number one byte can hold.
How do I convert a decimal colour like rgb(255, 128, 0) to hex?
Convert each channel to two hex digits and join them: 255 = FF, 128 = 80, 0 = 00, so the colour is #FF8000. The colour converter does all three at once.
Why does hex use letters?
Base 16 needs a single symbol for each value from 0 to 15, but there are only ten numerals. The letters A to F fill the gap for 10 to 15.