GetToolSpace

Free Online Converter

Decimal to Hex Converter

Convert a decimal number to hexadecimal instantly. Works with very large and negative numbers, and also shows the value in binary and octal.

Try an example:
Output options

Hexadecimal result

Your result will appear here.

Your numbers stay in your browser. They are not uploaded or saved.

The same number in other number systems

Enter a number above to see it in binary and octal as well.

Need to convert the other way? Hex to Decimal Converter

How to Convert Decimal to Hexadecimal

This guide explains how hexadecimal works, the method behind the converter above, and the values you will use most often.

What is hexadecimal?

Hexadecimal, or hex, is a number system with a base of 16. Decimal, the system we use every day, has ten digits (0 to 9). Hexadecimal needs sixteen, so after 9 it continues with the letters A to F. A stands for 10, B for 11, C for 12, D for 13, E for 14 and F for 15.

Hex is popular in computing because one hex digit matches exactly four binary digits (bits). A byte, which is eight bits, is always two hex digits. That makes hex a short, readable way to write values that are long in binary.

How to convert decimal to hex

The standard method is repeated division by 16. Divide the number by 16 and write down the remainder. Then divide the quotient by 16 again, and keep going until the quotient is 0. The remainders, read from the last one to the first, are the hex digits. Any remainder from 10 to 15 is written as A to F.

Method

Divide by 16, note the remainder, repeat with the quotient until it is 0, then read the remainders from bottom to top.

Example: convert 750 to hex

750 ÷ 16 = 46 remainder 14 (E)

46 ÷ 16 = 2 remainder 14 (E)

2 ÷ 16 = 0 remainder 2

Reading the remainders from the bottom up gives 2EE.

Check: 2 × 256 + 14 × 16 + 14 = 750.

Why 255 is FF

The number 255 is the largest value that fits in one byte, so it is one of the most common numbers you will convert.

Example: convert 255 to hex

255 ÷ 16 = 15 remainder 15 (F)

15 ÷ 16 = 0 remainder 15 (F)

Reading upward gives FF.

Decimal, hexadecimal and binary from 0 to 15

Every hex digit is a value from 0 to 15. Learning this short table makes all other conversions easier.

Decimal values 0 to 15 with their hexadecimal and binary equivalents
DecimalHexadecimalBinary
000000
110001
220010
330011
440100
550101
660110
770111
881000
991001
10A1010
11B1011
12C1100
13D1101
14E1110
15F1111

Common decimal to hex values

Common decimal numbers and their hexadecimal values
DecimalHexadecimal
10A
1610
10064
255FF
256100
1,0003E8
4,095FFF
65,535FFFF

Negative numbers

This converter shows a negative number with a minus sign, so -255 becomes -FF. Computers usually store negative numbers in a different form called two's complement. To get the two's complement for a fixed width, add 2 raised to the number of bits to the negative value. For example, -1 in 8 bits is -1 + 256 = 255, which is FF.

Where hexadecimal is used

  • Programming: memory addresses, byte values and the 0x prefix used in languages such as C, JavaScript and Python.
  • Web design: colour codes such as #FF8800 store red, green and blue as three hex pairs.
  • Networking: MAC addresses and IPv6 addresses are written in hex.
  • Debugging and file formats: hex editors and error codes show raw bytes as hex.

Frequently Asked Questions

How do I convert decimal to hexadecimal?

Divide the decimal number by 16 repeatedly and write down each remainder, using A to F for remainders 10 to 15. When the quotient reaches 0, read the remainders from last to first. You can also type the number into the converter above and get the answer instantly.

What is 255 in hex?

255 in decimal is FF in hexadecimal. It is 15 × 16 + 15, and both 15s are written as F.

Why do programmers use hexadecimal?

One hex digit represents exactly four bits, so a byte is always two hex digits. Hex is much shorter than binary and far easier to convert to and from it than decimal is.

Can this converter handle very large numbers?

Yes. It uses arbitrary-precision integers, so the result is exact even for numbers far above the limit of a normal calculator. For example, 18446744073709551615 converts exactly to FFFFFFFFFFFFFFFF. Input is limited to 2,000 characters.

Does it support decimal fractions such as 10.5?

No. The converter works with whole numbers only. Remove the fractional part before converting.

What does the 0x prefix mean?

0x is not part of the number. Many programming languages write it in front of a value to show that it is hexadecimal. Tick "Add 0x prefix" if you want it included in the result.

Are the numbers I enter saved?

No. Every conversion runs in your browser, and your numbers are not sent to our server or stored.

Important Note

This converter gives mathematical results for whole numbers. For work where a wrong value matters, such as firmware or security, double-check the result in your own tools.