Decimal to Hex Converter Tool
Whole numbers only. Very large numbers are handled exactly with BigInt, so there is no rounding from floating point maths.
Decimal is the base 10 system we use every day. Hexadecimal is base 16, and it uses digits 0 to 9 plus letters A to F, where A is 10 and F is 15. Programmers use hex for colours, memory addresses, and byte values because one hex digit stands for exactly 4 bits.
How to Use This Tool
- Enter a decimal number: type a whole number, positive or negative.
- Click Convert: the hex result appears at once, with uppercase, lowercase, and 0x forms.
- Read the steps: the division steps show how the answer was reached.
- Copy the result: paste it into code, a colour value, or a document.
The Formula
Divide the decimal number by 16 again and again, and write down each remainder. Remainders 10 to 15 become A to F. Read the remainders from bottom to top. For example, 255 divided by 16 is 15 remainder 15, and 15 divided by 16 is 0 remainder 15, so 255 in hex is FF.
Worked Examples
| Decimal | Hex | Use |
|---|---|---|
| 0 | 0 | Zero, the null byte |
| 1 | 1 | One, a single hex digit |
| 2 | 2 | Two, a single hex digit |
| 3 | 3 | Three, a single hex digit |
| 4 | 4 | Four, a single hex digit |
| 5 | 5 | Five, a single hex digit |
| 6 | 6 | Six, a single hex digit |
| 7 | 7 | Seven, a single hex digit |
| 8 | 8 | Eight, a single hex digit |
| 9 | 9 | Nine, a single hex digit |
| 10 | A | Ten, the first letter digit |
| 11 | B | Eleven, a letter digit |
| 12 | C | Twelve, a letter digit |
| 13 | D | Thirteen, a letter digit |
| 14 | E | Fourteen, a letter digit |
| 15 | F | Fifteen, the last letter digit |
| 16 | 10 | Sixteen, the first two digit hex value |
| 100 | 64 | A common test value |
| 256 | 100 | The count of values one byte can hold |
| 1000 | 3E8 | A round decimal value |
| 4096 | 1000 | Four kilobytes |
| 65535 | FFFF | The largest value in two bytes |
| 16777215 | FFFFFF | The largest 24 bit colour value |
Why Use Hex
Hex is shorter than binary and easier to read than long decimal strings when you work with bytes. A single byte, 0 to 255, is always exactly two hex digits, from 00 to FF. That fixed width is why hex shows up in colour codes, where each colour channel is one byte, and in memory addresses, where a long binary address becomes a short hex string. When you debug code, hex lets you spot a wrong byte at a glance instead of counting 0s and 1s. Programmers also use hex in file formats, network packets, and character codes, because one hex digit maps to exactly four bits and never needs padding to line up.
What Is Hexadecimal?
Hexadecimal is a number system with base 16. It uses the digits 0 to 9 and the letters A to F, where A stands for 10, B for 11, C for 12, D for 13, E for 14, and F for 15. One hex digit holds exactly four bits, which is called a nibble, and two hex digits hold one byte. That neat fit is why programmers use hex everywhere they work with bytes. You see hex in colour codes like #FF5733, where FF is the red value, 57 is green, and 33 is blue. You also see it in memory addresses, in file hashes, in MAC addresses, and in error codes. When you debug code, hex makes long binary values short enough to read at a glance. A byte can hold any value from 00 to FF, which is 0 to 255 in decimal.
Decimal to Hex in Code
If you convert decimal to hex in code instead of a tool, here is how in four common places. The examples below all convert 255, and each one gives FF.
JavaScript and Python give lowercase hex, so convert the result to uppercase if you need FF instead of ff. Excel gives uppercase FF already. In Java, toHexString also gives lowercase, so call toUpperCase on the result if you need FF.
Hex is one of several number conversions on this site. To go the other way, use the Hex to Decimal Converter. To convert binary to hex, use the Binary to Hex Converter, and to convert binary to decimal, use the Binary to Decimal Converter. For octal, use the Octal to Decimal Converter, the Binary to Octal Converter, the Octal to Binary Converter, or the Octal to Hex Converter. To convert text, use the Text to Hex Converter or the Text to ASCII Converter.
Frequently Asked Questions
Yes. It is free, needs no sign up, and runs in your browser.
Yes. It uses BigInt, so very large whole numbers convert exactly, with no floating point rounding.
Yes. Enter a minus sign and the result keeps the minus sign in front of the hex digits. This tool does not use two's complement, so negative 1 shows as -1, not FF.
255 in hex is FF, because 15 times 16 plus 15 is 255, and 15 is F in hex.
No. It works in any modern browser on a phone, tablet, or computer.
0x is a prefix that marks a number as hexadecimal. It tells you the digits that follow are in base 16, not base 10. This tool shows the 0x form in its result, and you can write 0xFF in code to mean 255.
In Excel, use the DEC2HEX function. Type =DEC2HEX(255) in a cell, and Excel returns FF. DEC2HEX works with whole numbers only, just like this tool.
In Python, use hex(255), which returns 0xff. In JavaScript, use (255).toString(16), which returns ff. Both give lowercase hex, so convert the result to uppercase if you need FF.
Split the colour into red, green, and blue values from 0 to 255, convert each one to two hex digits, and join them after a hash sign. For example, red 255, green 87, and blue 51 becomes #FF5733. This tool converts one number at a time, so convert each of the three values in turn.
No. This tool works with whole numbers only. A value like 12.5 is not accepted, so convert the whole part only.