Decimal to Hex Converter

Convert decimal to hex as you type and see the repeated division by 16 that produces each digit. Works for numbers of any size, and gives the two's complement hex of negative numbers.

Whole numbers of any size. Commas and spaces are ignored, and a minus sign is allowed.

Hexadecimal number

The same number in every base
Binary
Octal
Decimal
Hex
Bit length
Show steps

Divide the decimal number by the new base again and again until the quotient is 0. The remainders, read from the bottom up, are the digits of the result.

DivisionQuotientRemainderDigit

Two's complement view (signed numbers)

Auto picks the smallest of 8, 16, 32 or 64 bits that holds the number as a signed value.

Width
Bits
Hex
Unsigned
Signed

Convert Decimal Numbers to Hexadecimal Online

Programmers write numbers in hex because every hex digit is exactly 4 bits, which makes bytes, masks and addresses short and easy to read. This decimal to hex converter writes any whole number in base 16 while you type.

The steps table shows the repeated division by 16 for your number, with each remainder turned into its hex digit. Add a 0x prefix for code, or use the two's complement view to get the hex of a negative number.

Decimal number converted to hexadecimal488790xBEEFDecimal toHex

How to use the decimal to hex converter

  1. Type a decimal number, for example 48879.
  2. Copy the hex result, BEEF. Tick "Show prefix" to get 0xBEEF.
  3. Check the steps, or open the two's complement view for negative numbers.

How to convert decimal to hex: divide by 16

Divide the number by 16 and note the remainder (0 to 15). Divide the quotient by 16 again until it reaches 0. Write remainders 10 to 15 as A to F, then read them from the bottom up. For 48879:

DivisionQuotientRemainder
48879 ÷ 16305415 = F
3054 ÷ 1619014 = E
190 ÷ 161114 = E
11 ÷ 16011 = B

Reading upward gives BEEF. Check: 11 × 4096 + 14 × 256 + 14 × 16 + 15 = 48,879.

Shortcut: go through binary

If you already know the binary form, split it into groups of 4 bits from the right and replace each group with one hex digit. 200 is 1100 1000 in binary, and 1100 = C, 1000 = 8, so 200 is C8. The decimal to binary converter groups bits in fours for you.

Decimal to hex table

DecimalHexDecimalHex
10A255FF
15F256100
16101,0003E8
32201,024400
64404,0961000
1006465,535FFFF
1277F65,53610000
128801,000,000F4240

Negative numbers in hex

Computers store −1 with every bit set, so in two's complement it is FF in 8 bits, FFFF in 16 bits and FFFFFFFF in 32 bits. For other values, add 2width: −42 in 8 bits is 256 − 42 = 214, which is D6.

With a plain minus sign the converter writes -2A for −42. The two's complement view gives the bit pattern for 8, 16, 32 or 64 bits.

Where decimal to hex is used

  • CSS colors: rgb(79, 70, 229) is 4F, 46 and E5, so #4F46E5. The RGB to HEX converter does all three channels at once.
  • Unicode and HTML: 9786 is 263A, so ☺ shows ☺.
  • Code: Python hex(255) gives 0xff, and JavaScript (255).toString(16) gives ff.

Frequently Asked Questions

Common questions about converting decimal numbers to hexadecimal.

Divide by 16 repeatedly, write down each remainder as a hex digit (10 = A … 15 = F) and read them from the last to the first. 255 gives 15 and 15, so it is FF.

255 is FF, the largest value of one byte.

16 is 10 in hex: one sixteen and zero ones.

1000 is 3E8: 3 × 256 + 14 × 16 + 8.

Two. A byte is 8 bits and each hex digit is 4 bits, so values 0 to 255 are 00 to FF.

It does not matter: FF and ff are the same value. The converter uses upper case, which is easier to read.

Use the two's complement view and choose a width. -1 is FF in 8 bits and FFFFFFFF in 32 bits.

Use the hex to decimal converter, which adds up the powers of 16.