Convert any decimal (base 10) number to hexadecimal (base 16) instantly. Shows step-by-step division, binary and octal equivalents, and a hex digit reference table.
✓Verified: April 2026
Enter a whole number from 0 to 4,294,967,295.
Enter any non-negative integer
Hexadecimal (Base 16)
—
Was this calculator helpful?
Thanks for your feedback!
Was this calculator helpful?
✓ Thanks for your feedback!
Sources & Methodology
✓Hexadecimal (base 16) is defined by IEEE and ANSI standards and is fundamental to computer architecture, memory addressing, and digital color systems.
Reference for hexadecimal use in HTML/CSS color codes and web design
Method: Repeated division by 16. Remainders 0–9 are written as digits; remainders 10–15 as letters A–F. Read remainders bottom to top. Nibble display: Each hex digit = 4 binary bits (one nibble). 0x prefix: Standard programming notation indicating a hexadecimal literal.
JavaScript conversion: n.toString(16).toUpperCase() — exact for integers up to 253−1.
⏱ Last reviewed: April 2026
How to Convert Decimal to Hexadecimal
Hexadecimal (base 16) is one of the most important number systems in computing. Unlike binary (base 2) which requires many digits to represent large numbers, hexadecimal provides a compact, human-readable representation. Each hex digit corresponds to exactly four binary bits (a nibble), making it ideal for representing bytes, memory addresses, color codes, and machine instructions.
The Division-by-16 Method
Hex = remainders of (n÷16) read bottom to top, where 10=A, 11=B, 12=C, 13=D, 14=E, 15=F
HTML and CSS color codes use 6 hex digits in the format #RRGGBB, where RR, GG, and BB are the red, green, and blue channel values in hex (00–FF). White is #FFFFFF (255, 255, 255). Black is #000000 (0, 0, 0). Pure red is #FF0000 (255, 0, 0). Understanding decimal-to-hex conversion is essential for working with color values in web design and graphics programming.
💡 Hex-to-binary shortcut: Each hex digit = exactly 4 binary bits. To convert hex FF to binary: F=1111, F=1111 → 11111111. This makes hex a compact shorthand for binary — two hex digits always equal one byte (8 bits).
Frequently Asked Questions
Divide by 16 repeatedly, recording remainders 0–9 as digits and 10–15 as A–F. Read remainders bottom to top. Example: 255 ÷ 16 = 15r15(F), 15 ÷ 16 = 0r15(F) → read bottom to top: FF.
Decimal 255 = hex FF. This is the maximum value of an 8-bit byte, all bits set to 1 (11111111 in binary). FF is used in RGB colors (#FFFFFF = white), subnet masks, and as the null-check byte value in many protocols.
Decimal 10 = hex A. Hexadecimal uses letters A through F to represent values 10 through 15, allowing each single digit to represent 4 binary bits. Decimal 10 = hex A = binary 1010.
Decimal 16 = hex 10. Since 16 is the base of hexadecimal, it works just like decimal 10 in base 10 — the first two-digit number. Hex 10 means (1 × 16) + (0 × 1) = 16.
Use hex(n) for lowercase (hex(255) = '0xff'), or format(n,'X') for uppercase without prefix (format(255,'X') = 'FF'). For zero-padded output: format(255,'02X') = 'FF', format(255,'04X') = '00FF'.
=DEC2HEX(255) returns FF. =DEC2HEX(255,4) returns 00FF (4 characters). Excel's DEC2HEX supports values up to 549,755,813,887. For larger numbers or more control, use Python or JavaScript.
Hexadecimal uses 0–9 and A, B, C, D, E, F. A=10, B=11, C=12, D=13, E=14, F=15. Letters can be uppercase or lowercase (FF = ff). This allows each digit to represent a full nibble (4 bits), making two hex digits equal exactly one byte.
0xFF in decimal is 255. The 0x prefix indicates hexadecimal in programming. FF = (15×16) + (15×1) = 240+15 = 255. 0xFF is the maximum single-byte value and is widely used as a bit mask, max color value, and byte boundary marker.
Each hex digit = exactly 4 binary bits: 0=0000, 1=0001...9=1001, A=1010, B=1011, C=1100, D=1101, E=1110, F=1111. So binary 11111111 = hex FF. Two hex digits always = 8 bits (one byte). This direct correspondence makes hex ideal for representing binary data compactly.
White=#FFFFFF, Black=#000000, Red=#FF0000, Green=#00FF00, Blue=#0000FF, Yellow=#FFFF00, Orange=#FFA500. Each pair of hex digits is one RGB channel from 00 (0 decimal) to FF (255 decimal). Understanding decimal-to-hex lets you read and write color codes directly.
Hex is used in: HTML/CSS colors (#FF5733), memory addresses (0x7FFF4B2A), machine code and assembly, IPv6 (2001:0db8:85a3::1), file magic bytes, Unicode code points (U+1F600), cryptographic hashes (SHA-256 outputs), and any context where binary data needs a compact human-readable form.
Decimal 100 = hex 64. Division: 100÷16=6r4, 6÷16=0r6 → 64. Verify: 6×16+4=100. The constant 0x64 is common in programming for representing the decimal value 100, and 100% in some byte-scaled ranges maps to 0x64.