Decimal to Hex
Convert decimal to hexadecimal instantly.
How to use this tool
- Enter decimal in the fields above.
- Results update instantly as you type — or click Calculate.
- Read your hexadecimal and the full breakdown beneath it.
Convert decimal to hexadecimal instantly.
Formula
Hexadecimal = successive division of the decimal number by 16, reading remainders (mapped to 0–9, a–f) from bottom to top
hex = decimal.toString(16)
For example, 255 ÷ 16 = 15 R15 → 15 ÷ 16 = 0 R15; remainders 15,15 → ff.
How it works
Repeatedly divide the decimal integer by 16, recording each remainder. Map remainders 10–15 to the letters a–f. When the quotient reaches 0, stop and read the remainders in reverse to get the hexadecimal string. JavaScript's Number.prototype.toString(16) performs this automatically and returns lowercase letters.
Common mistake: Forgetting to map remainders of 10–15 to their letter equivalents (a–f) and instead writing them as two-digit numbers (e.g., writing "1015" instead of "ff") is a very common hand-calculation error.
Worked example
Convert decimal 255 to hexadecimal
- Divide 255 by 16: quotient 15, remainder 15 (maps to 'f').
- Divide 15 by 16: quotient 0, remainder 15 (maps to 'f').
- Read remainders bottom to top: f, f.
ff — decimal 255 equals hexadecimal ff.
Common mistakes to avoid
- Mapping remainders of 10-15 to numerals 10-15 (two digits) instead of to letters A-F, producing invalid hex.
- Reading remainders in the order computed rather than in reverse, which reverses the hex digits.
- Assuming the output is case-sensitive and mixing cases — hex is conventionally all-uppercase or all-lowercase, not mixed.
Key terms
- Hexadecimal (base-16)
- A compact number notation using digits 0–9 and letters a–f, widely used in computing for memory addresses and color codes.
- Remainder mapping
- Translating a numeric remainder of 10–15 to the corresponding hex letter: 10→a, 11→b, 12→c, 13→d, 14→e, 15→f.
- toString(16)
- A JavaScript method that converts an integer to its hexadecimal string representation in lowercase.
- Byte
- An 8-bit unit of data; always representable as exactly two hexadecimal digits (00 to ff), which is why hex is so common in computing.
Frequently asked questions
- What is decimal 255 in hex?
- 255 = FF in hex (15 x 16 + 15).
- When would I need to convert decimal to hex?
- Common uses include memory addresses, color codes (CSS/HTML), file format offsets, and programming bitmasks.
- What is the largest two-digit hex number in decimal?
- FF = 255. The largest four-digit hex number is FFFF = 65,535.