ToolNimba

# Decimal to Hex Converter: Convert Decimal Numbers to Hexadecimal

Shihab Mia By Shihab Mia ยท Updated 2026-07-10

Hex (uppercase)
FF
With 0x prefix
0xFF
Decimal in
255
Binary
11111111
Octal
377
Hex digits
2
Bytes (padded)
FF
Repeated division by 16 (read remainders bottom to top)
Step Divide Quotient Remainder Hex digit

To convert decimal to hex, divide the number by 16 repeatedly and read the remainders from bottom to top, mapping 10 to 15 as A to F; for example, decimal 255 becomes FF (written 0xFF). This decimal to hex converter does that instantly and shows every division step, so you get the exact uppercase result plus the binary and octal equivalents. Enter any non-negative whole number, from a single byte value to a large 64-bit integer, and read off the answer.

What is the Decimal to Hex Converter?

Hexadecimal is base 16, which means each digit position represents a power of 16 and uses sixteen symbols: 0 to 9 for values zero to nine, then A, B, C, D, E and F for values ten to fifteen. A decimal to hex conversion re-expresses the same quantity in this base. Because 16 is a power of 2 (16 = 2 to the 4th power), every hex digit maps cleanly to exactly four binary bits, which is why programmers reach for hex to write byte and color values compactly. Decimal 255, the largest value in a single byte, is FF in hex and 11111111 in binary, and that tidy relationship is the whole reason hex exists.

The core method behind any decimal to hex conversion is repeated division by 16. Divide the decimal number by 16, note the remainder, then divide the quotient by 16 again, and keep going until the quotient reaches zero. Each remainder is a hex digit, with any remainder from 10 to 15 written as its letter A to F. The catch that trips people up is order: the first remainder you calculate is the least significant digit, so you read the collected remainders from the last one back to the first, that is bottom to top. For 3000, the remainders come out 8, 11 (B) and 11 (B), giving BB8, so 3000 in decimal is 0xBB8.

In practice you rarely divide by hand. In JavaScript the expression n.toString(16).toUpperCase() returns the uppercase hex string directly, Python uses hex() or format(n, "X"), and most languages expose a similar base-conversion call. This converter uses BigInt internally, so it stays exact even for very large integers where ordinary floating point numbers would silently lose precision past 2 to the 53rd power. The decimal to hex result is shown three ways, as plain digits, with the conventional 0x prefix, and split into padded byte pairs, so you can paste it straight into code, a color picker, or a memory dump.

Hex shows up everywhere once you know to look: web colors like #FF5733, memory addresses in a debugger, MAC addresses, Unicode code points such as U+1F600, and the raw bytes of any file viewed in a hex editor. Being able to move between decimal and hex confidently means you can read an RGB channel value of 200 as C8, spot that a 32-bit limit of 4294967295 is FFFFFFFF, and sanity-check numbers that would otherwise look opaque. The decimal to hex converter below gives you the answer and the working, so it doubles as a way to actually learn the method rather than just trusting a black box.

When to use it

  • Turn an RGB or grayscale channel value like 200 into its hex pair C8 for a CSS color such as #C8C8C8.
  • Convert a decimal memory offset or address into hex to match what a debugger, disassembler or hex editor displays.
  • Check your homework or exam answer for a base 10 to base 16 conversion and see the full division-remainder working.
  • Encode a decimal byte or word value as hex before writing it into a config file, packet, or firmware constant.

How to use the Decimal to Hex Converter

  1. Type a non-negative whole number into the input field (the default 255 is already filled in for you).
  2. Read the uppercase hex result and the 0x-prefixed version in the result cards at the top.
  3. Scroll the division table to follow the repeated-division-by-16 steps and see each remainder become a hex digit.
  4. Use the Copy buttons to grab the hex, 0x, binary or octal value, or click a sample number to try another input.

Formula & method

Repeated division by 16: while the number > 0, record remainder = number mod 16 (write 10 to 15 as A to F), then set number = floor(number / 16). Read the remainders in reverse (bottom to top) to get the hex string. Equivalently, each hex digit dk satisfies value = sum of dk x 16k. Shortcut in code: hex = n.toString(16).toUpperCase().
Decimal 255 to Hex255Divide by 16, keep remainder255 / 16 = 15 rem 15F15 / 16 = 0 rem 15FRead remainders bottom to topFF = 0xFF

Worked examples

Convert decimal 255 (a single full byte) to hexadecimal.

  1. 255 / 16 = 15 remainder 15. Remainder 15 maps to the hex digit F.
  2. 15 / 16 = 0 remainder 15. Remainder 15 maps to F.
  3. Quotient is now 0, so stop.
  4. Read the remainders bottom to top: F then F.

Result: 255 in decimal = FF in hex = 0xFF.

Convert decimal 3000 to hexadecimal.

  1. 3000 / 16 = 187 remainder 8. Hex digit 8.
  2. 187 / 16 = 11 remainder 11. Remainder 11 maps to B.
  3. 11 / 16 = 0 remainder 11. Remainder 11 maps to B.
  4. Read bottom to top: B, B, 8.

Result: 3000 in decimal = BB8 in hex = 0xBB8.

Decimal to hex digit map (single hex digits 0 to 15)

DecimalHexBinary (4 bits)
000000
110001
881000
991001
10A1010
11B1011
12C1100
13D1101
14E1110
15F1111

Common decimal to hex conversions worth memorizing

DecimalHexWhere you see it
1610First two-digit hex value
10064Round decimal hundred
200C8RGB channel value
255FFMax value of one byte
256100One more than a byte
4095FFFMax 12-bit value
65535FFFFMax 16-bit unsigned
16777215FFFFFFMax 24-bit, white in RGB

Common mistakes to avoid

  • Reading the remainders in the wrong order. The first remainder you compute is the least significant (rightmost) hex digit, not the leftmost. Always read the collected remainders bottom to top. Reversing this turns BB8 into 8BB.
  • Forgetting to convert 10 to 15 into letters. A remainder of 12 is the single hex digit C, not the two characters 1 and 2. Every remainder from 10 to 15 must become A, B, C, D, E or F before you write it down.
  • Trying to convert negative or fractional numbers. Plain repeated division by 16 assumes a non-negative integer. Negative numbers need a signed representation such as two-complement, and fractions need a separate fractional-hex method. This tool validates the input and asks for a non-negative whole number.
  • Losing precision on very large numbers. Converting a huge value with ordinary floating point math can silently round it above 2 to the 53rd power. This converter uses BigInt so the decimal to hex result stays exact for large 64-bit and bigger integers.

Glossary

Hexadecimal (hex)
A base 16 number system using the sixteen symbols 0 to 9 and A to F, where each digit represents a power of 16.
Decimal (base 10)
The everyday number system using digits 0 to 9, where each position represents a power of 10.
Remainder
What is left over after an integer division; in decimal to hex conversion each remainder from dividing by 16 becomes one hex digit.
0x prefix
The conventional marker placed before a hex number in code, so 0xFF makes it clear the value is hexadecimal rather than decimal 255.
Nibble
A group of four bits, which corresponds to exactly one hexadecimal digit and can hold a value from 0 to 15 (0 to F).
Byte
A group of eight bits, representable as two hex digits, holding a value from 0 to 255 (00 to FF).

Frequently asked questions

What is 255 in hex?

255 in hex is FF, written 0xFF in code. It is the largest value that fits in a single 8-bit byte, and in binary it is 11111111, which is two groups of four 1s, or two F digits.

How do you convert decimal to hex by hand?

Divide the decimal number by 16 and write down the remainder, then divide the quotient by 16 again, repeating until the quotient is 0. Convert any remainder from 10 to 15 into A to F, then read the remainders from bottom to top to get the hex value.

What is the 0x prefix in a hex number?

The 0x prefix is a label that tells a programming language the number is hexadecimal, not decimal. So 0xFF means hex FF, which equals decimal 255, while plain FF without context could be mistaken for something else.

Why do programmers use hexadecimal instead of decimal?

Programmers use hex because 16 is a power of 2, so each hex digit maps exactly to four binary bits and one byte is just two clean hex digits. This makes colors, memory addresses and raw byte values far shorter and easier to read than long binary strings.

Can this tool convert very large numbers to hex accurately?

Yes. The converter uses BigInt internally, so it stays exact for very large integers, including full 64-bit values and beyond, where ordinary floating point conversion would lose precision above 2 to the 53rd power.

How do I convert an RGB color value like 200 to hex?

Convert each channel separately: 200 in decimal is C8 in hex, so an RGB value of (200, 200, 200) becomes the CSS color #C8C8C8. Each of the three channels is a number from 0 to 255 that turns into a two-digit hex pair from 00 to FF.