U.UtilityApp
🔄 ConvertersFree · No signup

Decimal to Hex Converter

Convert decimal numbers to hexadecimal (base-16).

Repeated division by 16

Divide the number by 16 and write down the remainder. Divide the quotient by 16 again and repeat until it reaches 0. The remainders, read from the last one up, are the hex digits, with 10 to 15 written as A to F. For 3054:

DivideQuotientRemainderHex digit
3054 ÷ 1619014E
190 ÷ 161114E
11 ÷ 16011B

Read upwards: BEE, which is what the converter shows. To check, multiply back: 11 × 256 + 14 × 16 + 14 = 3054.

When you need a decimal value written in hex

  • Constants in code. Masks and byte values are easier to read as hex: 255 is FF and 65535 is FFFF.
  • Unicode escapes. A character code of 8364 is 20AC, so the euro sign can be written as U+20AC or \u20AC.
  • Colour channels. A red value of 200 is C8. For a full colour with three channels, the RGB to HEX converter builds the code for you.
  • Memory sizes and offsets. 4096 bytes is 1000 in hex, a round number in the base the tools use.

Format of the result: capitals, no prefix, no padding

The result is written in capital letters with no 0x or # in front. Add the prefix your context needs: 0x in most programming languages, # only for a full colour code.

No leading zeros are added. 10 comes out as A, but a colour channel or a byte needs two digits, 0A. Pad on the left with zeros to the width you need.

Inputs that come out wrong

  • Decimals. The fraction is dropped: 3.75 gives 3. Hex fractions aren't supported.
  • Thousands separators. Reading stops at the comma, so 1,000 gives 1. Spaces are removed, so 1 000 works and gives 3E8.
  • Scientific notation. 1e3 gives 1. Type the full number.
  • Negative numbers. −255 gives −FF, a minus sign in front of the hex. A program storing −255 as a 32-bit integer holds the two's complement form, FFFFFF01, which this converter does not produce.
  • Very large numbers. Values above 9007199254740991 are rounded first. 9007199254740993 gives 20000000000000, which is the hex for 9007199254740992.

Frequently asked questions

What is 255 in hex?+

FF, the largest value two hex digits can hold. One more, 256, needs a third digit and is written 100.

How many hex digits will my number need?+

Each hex digit covers four bits. Numbers up to 15 fit in one digit, up to 255 in two, up to 4095 in three and up to 65535 in four.

Is uppercase hex different from lowercase?+

No. The converter writes BEE, but bee means the same number, and both forms are accepted almost everywhere hex is used, including CSS colour codes.

Embed this tool on your website

Free to use on blogs, school sites and intranets. Paste this code into your page's HTML; please keep the credit line.

<iframe src="https://utilityapp.lat/embed/convert/decimal-to-hex" title="Decimal to Hex Converter" width="100%" height="420" style="border:0;max-width:760px" loading="lazy"></iframe>
<p style="font-size:13px"><a href="https://utilityapp.lat/convert/decimal-to-hex">Decimal to Hex Converter</a> by UtilityApp</p>