Decimal to Hexadecimal Converter

Convert non-negative integers between decimal (base 10) and hexadecimal (base 16).

Convert Up to 53-bit Multi-base
Rate this calculator

Decimal ↔ Hexadecimal

Base-10 ↔ base-16 conversion

Instructions — Decimal to Hexadecimal Converter

1

Pick a direction

Switch between "Dec → Hex" and "Hex → Dec" using the toggle at the top. The input field accepts integers in decimal, or strings of 0–9 and A–F in hex.

2

Type the value

Enter the number to convert. The result panel updates as you type. Use the quick picks for common reference values (255, 256, 1024, 65535).

3

Adjust format

Switch UPPER ↔ lower for letter case, and add the 0x (C, Java, Python) or # (HTML, CSS) prefix when needed. The binary and octal forms appear in the grid as well.

Formulas

Decimal uses ten digits (0–9). Hexadecimal uses sixteen (0–9 and A–F). The conversion is a base-change operation: repeated division by 16 for decimal-to-hex, positional sum for hex-to-decimal.

Decimal to hexadecimal (positional)
$$ N = \sum_{i=0}^{k} d_i \cdot 16^{i} $$
The decimal value N equals the sum of each hex digit times the corresponding power of 16. The conversion finds the digits d_i.
Repeated division by 16
$$ N = q_0 \cdot 16 + r_0,\;\; q_0 = q_1 \cdot 16 + r_1,\;\; \ldots $$
Divide N by 16 and keep the remainder; divide the quotient again; repeat until the quotient is zero. Read the remainders bottom-up as hex digits (10–15 → A–F).
Worked example: 255 → FF
$$ 255 = 15 \cdot 16 + 15 = \text{F} \cdot 16 + \text{F} $$
255 divided by 16 is 15 remainder 15. Both digits are 15, which is F in hex. So 255 (dec) = FF (hex).
Hexadecimal to decimal
$$ N = d_k \cdot 16^{k} + d_{k-1} \cdot 16^{k-1} + \dots + d_0 $$
Multiply each hex digit by the appropriate power of 16 and sum. Example: A3 hex = 10 × 16 + 3 = 163 decimal.
Bytes and nibbles
$$ 1\,\text{byte} = 8\,\text{bits} = 2\,\text{hex digits} $$
One hex digit (a nibble) encodes 4 bits. Two hex digits encode one byte, which is why memory dumps and color codes use hex pairs.
Maximum value per width
$$ \text{max} = 16^{n} - 1 $$
n hex digits can represent values up to 16^n − 1. So 2 digits → 255, 4 digits → 65,535, 8 digits → 4,294,967,295.

Reference

Quick decimal-hex table
DecimalHexBinaryNote
10A1010Single nibble
161010000Hex base
100641100100
255FF11111111One byte max
256100100000000
10244001×2¹⁰1 KiB
409610001×2¹²
65535FFFF2¹⁶ − 1Two-byte max
10485761000002²⁰1 MiB
4294967295FFFFFFFF2³² − 1Four-byte max

Hex digit map

HexDecimalBinary
000000
110001
220010
330011
440100
550101
660110
770111
881000
991001
A101010
B111011
C121100
D131101
E141110
F151111

Article — Decimal to Hexadecimal Converter

The Decimal to Hexadecimal Converter

Hexadecimal is the base-16 number system with digits 0–9 and A–F (representing values 10 through 15). The decimal to hexadecimal conversion is repeated division by 16, collecting remainders. 255 becomes FF, 256 becomes 100, and 65,535 becomes FFFF. One hex digit encodes four bits, and two hex digits encode one byte.

Hex shows up everywhere in computing for one practical reason: it lines up perfectly with bytes. Decimal is great for humans but awkward for machines (one byte spans 0–255, three digits with irregular widths). Binary is great for machines but unreadable for humans. Hex is the working compromise — two characters per byte, easy to read, and trivial to convert back to binary.

What is hexadecimal?

Hexadecimal is a positional number system with sixteen digits. The first ten reuse the decimal digits 0–9. The remaining six use the letters A, B, C, D, E, F to stand for the values 10, 11, 12, 13, 14, 15. Like decimal, each position is a power of the base — but the base is 16 instead of 10, so the second-from-right column is the 16s column, the third is the 256s column, and so on.

Examples make the system click. The hex value A3 equals 10 × 16 + 3 = 163 in decimal. The hex value FF equals 15 × 16 + 15 = 255 — the largest value that fits in one byte. The hex value 1000 is 1 × 16³ + 0 + 0 + 0 = 4,096. The hex value FFFFFFFF is 16⁸ − 1 = 4,294,967,295, the largest 32-bit unsigned integer.

Did you know

Bell Labs engineers experimented with hexadecimal in the 1960s alongside octal, and IBM standardised on hex for the System/360 architecture in 1964. The choice followed the byte: a byte is 8 bits, two hex digits cover all 256 possible byte values, but you would need three octal digits and waste half the third digit.

The decimal to hexadecimal algorithm

The standard method is repeated division by 16, reading the remainders bottom-up.

Decimal to hex steps
step 1 divide N by 16, keep remainder
step 2 repeat on quotient until 0
step 3 read remainders bottom-up
step 4 replace 10–15 with A–F

Worked example with 1000 decimal: 1000 ÷ 16 = 62 remainder 8. 62 ÷ 16 = 3 remainder 14 (E). 3 ÷ 16 = 0 remainder 3. Bottom-up the remainders are 3, E, 8, so 1000 (dec) = 3E8 (hex). Check by going the other way: 3 × 256 + 14 × 16 + 8 = 768 + 224 + 8 = 1000.

Hexadecimal to decimal (positional sum)

The reverse is a sum of digit × power. Right-to-left, the position values are 1, 16, 256, 4,096, 65,536, and so on. For each digit, multiply by its position value and add up the products.

Worked example with 7F2 hex: 7 × 256 + 15 × 16 + 2 × 1 = 1,792 + 240 + 2 = 2,034. Or in one line: 7F2 hex = 2,034 decimal. The same algorithm scales without modification — 1A2B3C in hex is 1 × 16⁵ + 10 × 16⁴ + 2 × 16³ + 11 × 16² + 3 × 16 + 12 = 1,715,004.

Hex, bytes, and nibbles

Each hex digit represents exactly four bits, a quantity sometimes called a nibble. Two hex digits, eight bits, make one byte. That alignment is why hex dominates over decimal and octal for byte-level work.

One byte in binary
11111111
8 characters
One byte in hex
FF
2 characters, same value

The conversion between hex and binary is purely substitutional. Replace each hex digit with its 4-bit binary equivalent: 0 → 0000, 1 → 0001, … A → 1010, … F → 1111. To go backwards, group bits in fours from the right and look each group up. No arithmetic is required at all.

  • 1 nibble = 4 bits = 1 hex digit
  • 1 byte = 8 bits = 2 hex digits
  • 1 word (16-bit) = 16 bits = 4 hex digits
  • 1 dword (32-bit) = 32 bits = 8 hex digits
  • 1 qword (64-bit) = 64 bits = 16 hex digits
  • MAC address = 48 bits = 12 hex digits (commonly with colons)

Hex in color codes and CSS

The most common encounter with hex outside programming is in web design. A CSS color of #FF5733 is three hex bytes for red, green, and blue. FF is full intensity for the red channel (255), 57 is mid-range green (87), 33 is low blue (51). Mixed, that gives a warm orange-red.

The shorthand #F53 expands to #FF5533 by repeating each digit — also valid CSS, also a different orange-red. Modern CSS supports four-digit and eight-digit hex forms that include alpha transparency (#FF5733CC for 80% opaque), but the three-byte form dominates in legacy code and design tools.

Tip

When debugging colors, convert the hex pair for each channel separately and read it as 0–255. #80C0E8 is 128, 192, 232 — a soft sky blue. The conversion table for common 0/40/80/C0/FF values (0, 64, 128, 192, 255) covers most colour-picker math.

Hex in memory dumps and addresses

Programmers see hex in memory addresses, register dumps, and crash logs. A 64-bit pointer might read 0x00007FFF80123ABC — sixteen hex digits encoding the address of some object. Most debuggers default to hex display for the same reason colour codes use it: byte alignment, compactness, easy bit-pattern recognition.

Magic numbers in file formats are usually quoted in hex. PNG files start with 89 50 4E 47 (the printable bytes are PNG). PDF starts with 25 50 44 46 (printable: %PDF). ZIP archives start with 50 4B (printable: PK, the initials of co-inventor Phil Katz). Hex makes these signatures readable at a glance.

Why hex instead of octal — a short history

Early computers used a mix of word sizes — 12, 18, 24, 36, even 60 bits — and octal (base 8) was a natural fit because 12, 18, and 36 are all multiples of 3. Octal digits map to three bits each. The DEC PDP-8 and IBM 7090 generations standardised on octal documentation.

The shift to byte-oriented machines in the 1960s changed the math. A byte is 8 bits, which divides cleanly into two 4-bit nibbles but not into three octal digits. Hex won by the end of the decade, and the rise of bytes (and 16-, 32-, 64-bit word sizes that are all multiples of 8) cemented it. Octal survives in a few places — Unix file permissions, escape sequences in some languages — but hex is the default modern radix for non-decimal display.

Common decimal to hex mistakes

Most hex errors are notation errors rather than arithmetic errors. The math is mechanical; the conventions are what trip people up.

  • treating leading zero as octal — in C, 0755 is octal 493, not decimal 755 (use 0x for hex)
  • skipping the 10→A jump — after 9 the next hex digit is A, not 10
  • case confusion — 0xFF and 0xff are identical in value; only style differs
  • byte order in multi-byte values — 0x1234 read backwards in memory is often 0x3412 (endian issue, not a conversion bug)
  • signed vs unsigned — 0xFF is 255 unsigned, but −1 in 8-bit two's-complement
  • mixing # and 0x — # is CSS-only; 0x is programming-language style
Hex exceeds JS safe integer above 2^53

JavaScript Number can hold integers up to 2^53 − 1 (≈ 9 × 10¹⁵, or 1FFFFFFFFFFFFF in hex). Larger hex values lose precision in standard JS arithmetic. For 64-bit hex handling, use BigInt or a string-based library. This calculator covers everyday values well within the safe range.

FAQ

255 (dec) = FF (hex). The math: 255 ÷ 16 = 15 remainder 15. Both digits are 15, which is F. Read bottom-up to get FF. A single byte can hold values 0–255, so FF is the largest one-byte value.
0x is a programmer prefix that marks the following digits as hexadecimal. It comes from C and is now standard in Java, Python, JavaScript, and most other languages. 0xFF means 255 decimal. CSS uses # instead for color codes.
16⁸ = 4,294,967,296 values (0 through 4,294,967,295). That is the full range of a 32-bit unsigned integer, which is why 8-digit hex (like 0xFFFFFFFF) appears everywhere in low-level programming.
Multiply each digit by a power of 16 and add. For A3: A is 10, so 10 × 16 + 3 = 163. For 1F4: 1 × 256 + 15 × 16 + 4 = 256 + 240 + 4 = 500. Memorise 16² = 256 and 16³ = 4,096 to save time.
Hex is much more compact. A byte (8 bits) is 8 characters in binary (11111111) but only 2 characters in hex (FF). A 32-bit memory address fits in 8 hex digits but needs 32 binary digits. Hex maps cleanly to bytes — each pair is exactly one byte.
FFFF = 65,535 decimal. That is 16⁴ − 1, the largest value that fits in a 16-bit unsigned integer. Four hex digits cover the full two-byte range, which is why old colour codes used four-digit and six-digit hex forms.
Yes — case does not affect the value. 0xFF = 0xff = 255 decimal. Upper case is more common in older code (C, Assembly); lower case dominates in modern JavaScript and Python style guides. Pick one for consistency.
Replace each hex digit with its 4-bit binary equivalent. A3 becomes 1010 followed by 0011, so 10100011. The mapping is fixed (0 → 0000, 1 → 0001, … F → 1111), and you do not need to compute the decimal value at all.