Decimal to Hex Converter

Enter a value below — binary and octal come along free

Type in any field — the others update as you type.

Hex ↔ Decimal Quick Reference

HexDecimal
00
11
22
33
44
55
66
77
88
99
A10
B11
C12

How to Convert Decimal to Hex

To convert a decimal number to hexadecimal, divide by 16 repeatedly and collect the remainders. Each remainder is one hex digit, produced right to left:

  1. Divide the number by 16 and note the remainder
  2. Divide the quotient by 16 and note that remainder
  3. Repeat until the quotient is 0
  4. Write the remainders in reverse order, using A–F for remainders 10–15

Step-by-Step Example

Convert 419 to hex:

  1. 419 ÷ 16 = 26, remainder 3
  2. 26 ÷ 16 = 1, remainder 10, written as A
  3. 1 ÷ 16 = 0, remainder 1
  4. Read the remainders bottom-up: 1A3

So 419 in decimal is 1A3 in hex. A quick sanity check in reverse: 1×256 + 10×16 + 3 = 419.

Why Programmers Write Numbers in Hex

Decimal is what humans count in; hex is a compact way to write what machines store. One byte holds values 0–255, which is exactly two hex digits — so hex lines up with the hardware in a way decimal never does:

  • Setting colors — a designer's "255, 102, 0" becomes #FF6600 in CSS.
  • Bit masks and flags — a permission value like 4095 is FFF in hex, and the pattern of set bits is visible at a glance.
  • Low-level protocols — checksums, opcodes and register values are specified in hex, but calculations often start from decimal.
  • Unicode code points — the character № is "number sign" U+2116; 8470 in decimal.

Getting the Notation Right

Where the hex value goes matters as much as the digits:

  • CSS colors take a # prefix: #FF6600
  • C, JavaScript, Python take 0x: 0xFF66
  • Assembly listings sometimes use an h suffix: FF66h

The digits are identical in all three — only the costume changes. And when a value must occupy a fixed width, pad with leading zeros: 255 as a two-byte value is 00FF, not FF.

Frequently Asked Questions

What is 255 in hex?

255 in decimal is FF in hexadecimal: 255 ÷ 16 = 15 remainder 15, and 15 is written F, giving FF. It is the highest value a single byte can store.

How do I convert decimal to hex by hand?

Divide the number by 16 repeatedly, keeping each remainder. Write the remainders in reverse order, using the letters A through F for remainders 10 through 15.

How do I write a decimal number as a hex color?

Convert each channel (0–255) to two hex digits and join them behind a #. For example red 255, green 102, blue 0 becomes #FF6600. Pad values under 16 with a leading zero: 10 becomes 0A.

Why does my hex value need leading zeros?

When a value must fill a fixed width — two digits per color channel, or a fixed-size field in a protocol — you pad with zeros on the left. The number 255 as a two-byte field is 00FF; the zeros change the width, not the value.

Going the other way? Use the Hex to Decimal Converter.