Decimal to hex converter

Enter a decimal number to get its hex value as written in code, colors and memory addresses.

Loading the tool…

Processing and privacy: The result is calculated inside your browser and your data is not sent to any server.

How to use it

  1. Enter decimal number and fraction digits if it does not end.
  2. The result appears straight away and updates as you edit.
  3. Copy the result, or copy a link that keeps the same values to share it.

How it is calculated

Whole part: divide by 16 again and again, note each remainder and read the remainders from last to first, writing 10 to 15 as A to F. Fraction part: multiply the fraction by 16 again and again and take the whole digit each time.

Example

Inputs: Decimal number = 255, Fraction digits if it does not end = 24. Result: Result in hexadecimal: FF.

255
FF

Limits and caveats

  • Negative numbers keep a minus sign in front of the magnitude; they are not shown in two's complement.
  • Up to 2000 digits before the point and 200 after it.
  • A fraction that does not end in the new base is cut at the number of digits you choose, without rounding.

Questions about this tool

How do I convert 255 to hex?

255 ÷ 16 = 15 remainder 15, then 15 ÷ 16 = 0 remainder 15. A remainder of 15 is written F, so the answer is FF.

What is the largest number it accepts?

Up to 2000 decimal digits with full precision, so 18446744073709551615 becomes FFFFFFFFFFFFFFFF exactly.

Can I use it for RGB colors?

Yes, one channel at a time: 255 becomes FF and 128 becomes 80, then write the three channels side by side.