Skip to content
ZeroServer.tools

Decimal to Hex Converter

Convert decimal (base 10) numbers to hexadecimal (base 16).

Hexadecimal

Decimal to hexadecimal, explained

Hexadecimal is base 16, using the digits 0–9 then A–F for the values 10–15. It is compact and maps cleanly to bytes, which is why it shows up in color codes, memory addresses, and hashes. For example 255 becomes ff. All conversion happens locally in your browser.

Built and maintained by Meet Shah · Last updated

What this tool is used for

  • Writing a colour value as a hex triplet from 0-255 channel numbers.
  • Producing a hex constant for a config file or a register write.
  • Converting a computed offset into the form a debugger or a hex editor expects.
  • Expressing a large decimal identifier compactly for a log line.
  • Producing a hex mask from a decimal value while checking bit arithmetic.

Frequently Asked Questions

How does the conversion work by hand?
Repeated division by 16, reading the remainders bottom-up: 255 ÷ 16 = 15 r 15, so FF. The remainders come out least-significant first, which is why they must be read in reverse — the commonest manual error.
Why is 255 significant?
It is the largest value in one byte (0xFF), so it marks a boundary everywhere: RGB channel maxima, unsigned char limits, and subnet masks. Recognising FF, FFFF and FFFFFFFF on sight makes overflow bugs immediately obvious.
How are negative numbers represented?
Through two's complement at a fixed width, so −1 is FF in 8 bits, FFFF in 16 and FFFFFFFF in 32. The hex is meaningless without knowing the width, which is why seeing FFFFFFFF in a log usually means −1, not four billion.
What prefix should I use?
0x in C-family languages and Python, # for CSS colours, and no prefix in many hex dumps. Without a prefix, a value like 10 is genuinely ambiguous — it is sixteen in hex and ten in decimal.
Why does hex appear in colour codes?
Because two hex digits are exactly one byte and each RGB channel is one byte. #FF8800 is three bytes read directly, with no arithmetic — something decimal notation cannot offer.
How wide should the output be padded?
To the width of the underlying type — two digits for a byte, eight for a 32-bit word. Unpadded hex loses the type information, which is exactly what makes a register dump readable.
Why does hex appear in error codes?
Because the bits carry structure — a facility code, a severity flag and an error number packed into one word. Reading it in decimal hides those boundaries, which is why Windows and macOS both report codes in hex.

Common errors and gotchas

  • Omitting the padding, so a single-digit result breaks a fixed-width field or a colour triplet.
  • Converting a negative number without deciding the width first, since two's complement needs one.
  • Assuming the tool adds a `0x` prefix, when the target format may require or forbid it.
  • Converting a decimal with a fractional part and silently losing it.
  • Producing lower-case hex where the consuming format specifies upper case, which some parsers enforce.

Related Converters tools

Private & free — this tool runs entirely in your browser.

IndieKitShip your Next.js startup in days.affiliate