Guide
Converting decimal numbers to hexadecimal
Decimal is what you type into a form; hexadecimal is what you meet in a CSS file, a port table, a packet capture or a crash report. Moving between them by hand means a short run of divisions, and this page prints each one so you can use it either as a shortcut or as a worked answer.
The method
Divide the number by 16. The remainder is a digit from 0 to 15, written as 0–9 and then A to F. Divide the quotient by 16 again and keep going until the quotient is zero. Read the remainders from the last to the first. Each step removes the least significant hex digit, in the same way that dividing by ten removes the last decimal digit.
Where the result is used
Colour channels run from 0 to 255, which is 00 to FF. TCP and UDP port numbers are often listed in hex in documentation. Unicode code points, error codes from operating systems and offsets in file formats are conventionally written in hex. A programmer who can move between the two quickly spots patterns, such as 65,535 being FFFF, that are invisible in decimal.
Options
Letters can be upper-case, the style of most specifications, or lower-case, the style of many web and Unix tools. The “Add 0x prefix” switch writes the C-style marker in front. “Group digits” splits long results into blocks. Several numbers can be pasted at once, one per line, and every line is converted; the step-by-step working explains the first line.
Edge cases
Single-digit results carry no leading zero, so 10 gives A. If you need two digits for a byte, pad it. Decimal fractions are possible: 255.5 becomes FF.8, because half is 8/16. Many fractions never end, such as 0.1, and are cut off after 24 digits with an ellipsis to show it.
Negative numbers are written with a minus sign: −255 is −FF. A processor would store it differently, usually as a two’s complement bit pattern, so use that calculator when a fixed-width pattern is what you need.
A worked example
The Sample button loads 2026. Dividing gives 2026 ÷ 16 = 126 remainder 10 (A), then 126 ÷ 16 = 7 remainder 14 (E), then 7 ÷ 16 = 0 remainder 7. The remainders read from the bottom are 7, E, A, so the answer is 7EA. To check it, work forward: 7 × 256 is 1,792, E (14) × 16 is 224, and A (10) adds 10; the total is 2,026. The box below also gives binary 11111101010 and octal 3752.
Limits
The page does the arithmetic and nothing more. It does not format colours, add alpha channels or pad to byte boundaries. It also does not know about integer sizes, so a value too big for a 32-bit variable converts without a warning; if the size matters, compare the answer against your type’s range yourself or use the two’s complement calculator, which reports the range.
Related tools
- Hex to Decimal converts back with a place-value table.
- Decimal to Binary uses the same repeated division with 2 as the divisor.
- Decimal to Octal does the same job in base 8.
- Number Base Converter covers any base from 2 to 36.
Checked against the current version of the Decimal to Hex on .

