Decimal to Hexadecimal Converter

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

Common Conversions

Decimal Hexadecimal
10 0xA
15 0xF
16 0x10
255 0xFF
256 0x100

About Hexadecimal

Hexadecimal (hex) is a base-16 number system that uses 16 distinct symbols: 0-9 represent values 0 to 9, and A-F represent values 10 to 15. Hex is commonly used in computing and programming to represent binary data in a more compact, human-readable format. For example, the RGB color white is represented as #FFFFFF in hex.

Related Number System Converters

  • Hexadecimal to Decimal
  • Decimal to Binary
  • Binary to Hexadecimal
  • Decimal to Octal

Converting by hand: dividing by 16

To turn a decimal number into hex, repeatedly divide by 16 and read the remainders from bottom to top. Take 500: 500 ÷ 16 = 31 remainder 4. Then 31 ÷ 16 = 1 remainder 15, and 15 in hex notation is F. Then 1 ÷ 16 = 0 remainder 1. Reading the remainders bottom-up gives 1, F, 4 — so 500 in decimal is 1F4 in hexadecimal. This tool does the same division internally via JavaScript's toString(16), then uppercases the letters and prefixes "0x", which is the standard notation for a hex literal in most programming languages.

Why hex instead of binary or decimal

Each hex digit represents exactly 4 binary bits (since 16 = 2⁴), so a byte (8 bits) is always exactly 2 hex digits — 500 in binary is 111110100 (9 digits), which is harder to scan than 1F4. That compactness is why hex shows up in memory addresses, color codes (#1F4 would need padding to #001F4 for a 6-digit RGB value, but the pattern holds), and byte-level debugging, where binary is too long to read at a glance and decimal doesn't align with byte boundaries at all.

Limits of this converter

It only accepts non-negative whole numbers — decimals and negative values are rejected before conversion, since two's-complement or fractional hex representations require different logic than a plain positive-integer division loop.