Menu

Decimal to Hex Converter

Type a whole number and read it in hexadecimal, with each division by 16 shown underneath. It opens on 255, which is FF.

By Nethanel Bar, Co-founder & CEO

Last updated

Ready to actually learn to code?

Coddy teaches you by writing real code in your browser - interactive lessons, instant feedback, and AI help when you get stuck.

How to convert decimal to hexadecimal

Each division by 16 leaves a remainder from 0 to 15, and that remainder is the next hex digit from the right. For 500: 500 ÷ 16 = 31 remainder 4, 31 ÷ 16 = 1 remainder 15 (F) and 1 ÷ 16 = 0 remainder 1. Read upward, that is 1F4.

If you already have the binary form, there is a shortcut: split the bits into groups of four from the right and turn each group into one hex digit. The binary to hex converter shows that method.

The converter writes out the division steps for any whole number and uses BigInt, so 64-bit values stay exact.

What to know about writing numbers in hex

  • Remainders from 10 to 15 become the letters A to F.
  • Every whole number from 0 to 255 fits in two hex digits, which is why bytes are written in hex.
  • Multiplying by 16 adds a 0 to the end of a hex number: 15 is F and 240 is F0.
  • Web colors, memory addresses and Unicode code points are all written in hex.

Decimal to hex, worked out

255

Decimal

255

Hex

FF

255 ÷ 16 = 15 remainder 15, then 15 ÷ 16 = 0 remainder 15. Both remainders are F.

A color

Decimal

rgb(255, 136, 0)

Hex

#FF8800

Convert each channel on its own: 255 is FF, 136 is 88 and 0 is 00.

500

Decimal

500

Hex

1F4

The remainders are 4, 15 and 1. Read upward, with 15 written as F, they give 1F4.

A Unicode code point

Decimal

128512

Hex

1F600

128512 is the code point of the grinning face emoji, written U+1F600.

Common decimal to hex mistakes

  • Writing a remainder from 10 to 15 as two digits. 12 is the single digit C.
  • Reading the remainders in the order they were found. The first remainder is the rightmost digit.
  • Dropping a needed leading zero. In a color, 0 must be written 00 so each channel keeps two digits.
  • Mixing up hex and decimal output in code. 0x10 is 16, so mark hex values with a 0x prefix.

Decimal to hex FAQ

What is 255 in hex?
FF. 255 is 15 × 16 + 15, and 15 is written F.
What is 100 in hex?
64. 100 ÷ 16 = 6 remainder 4, so the hex digits are 6 and 4.
How do I convert decimal to hex in Python or JavaScript?
In Python, hex(255) returns '0xff' and format(255, 'X') returns 'FF'. In JavaScript, (255).toString(16) returns 'ff'.
Why do programmers use hex instead of decimal?
One hex digit is exactly four bits, so a byte is always two hex digits. Binary data is far easier to read that way than in decimal, where byte boundaries don't line up with the digits.

Learn more

Other developer tools

Coddy programming languages illustration

Learn to code with Coddy

GET STARTED