Convert hex to decimal, or any number between hexadecimal, decimal, binary, octal and bases 2 to 36, and see the working: every digit times its place value for the conversion into decimal, and the repeated division for the way back. The converter also shows the signed two’s complement value, Gray code and the bits needed, and it stays exact for numbers far beyond 64 bits.

Prefixes 0x, 0b and 0o, a leading #, spaces and underscores are accepted. Use a dot for fractions (for example 1A.8) and a minus sign for negative numbers.

Step-by-step working

DigitValuePlace valueDigit × place

Number÷ baseQuotientRemainderDigit

How to use the hex to decimal converter

Type a number, pick the base it is written in, and every other base appears at once with a copy button. The working below the results shows exactly how the answer was reached, so you can check homework or a datasheet value by hand.

  1. Enter the number. 0x1F, #1F, 1Fh and 1f all read as hexadecimal 1F when the input base is 16.
  2. Choose the input base: hexadecimal, decimal, binary, octal or any other base from 2 to 36.
  3. Read the decimal, hex, binary (grouped in fours), octal and your extra base. For whole numbers you also get the Gray code, the bits needed and the signed value.
  4. Open the step-by-step working: table 1 converts your number into decimal, and table 2 divides the decimal value back down into base 16, 2 or 8.

How to convert hex to decimal by hand

Multiply each hex digit by 16 raised to its position, counting from 0 at the right, then add the results. The letters A to F stand for the values 10 to 15.

Hex to decimal value = dₙ × 16ⁿ + … + d₂ × 16² + d₁ × 16¹ + d₀ × 16⁰
Example 7DE = 7 × 256 + 13 × 16 + 14 × 1 = 1,792 + 208 + 14 = 2,014
Example 3B = 3 × 16 + 11 = 59

The same method works for every base: binary uses powers of 2, octal powers of 8. Digits after a dot use negative powers, so hex 1A.8 is 16 + 10 + 8 ÷ 16 = 26.5.

How to convert decimal to hex

Divide the decimal number by 16 again and again, write down each remainder, and stop when the quotient reaches 0. The remainders read from the last to the first are the hex digits.

Example: 61,453 to hex
61,453 ÷ 16 = 3,840 remainder 13 → D
3,840 ÷ 16 = 240 remainder 0 → 0
240 ÷ 16 = 15 remainder 0 → 0
15 ÷ 16 = 0 remainder 15 → F
Result read bottom up: F00D

Table 2 in the converter shows the same division for any number, into hex, binary or octal. For binary the divisor is 2, so each remainder is a 0 or a 1.

Hex to binary: one hex digit is four bits

Each hex digit maps to exactly four binary digits, so you can convert between hex and binary digit by digit without going through decimal. That is why programmers write bytes as two hex digits: 1111 1111 is FF. Text is stored the same way, one number per character, and our ASCII art generator draws whole pictures with those printable characters.

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

Example: hex 2F = 0010 1111 in binary. Going the other way, split a binary number into groups of four from the right and look up each group: 1 1010 0110 = 1A6.

Hex to decimal chart: values you meet in computing

Some hex values come up again and again because they sit on a power-of-two boundary: FF is the largest byte, FFFF the largest 16-bit number and FFFFFFFF the largest 32-bit number.

HexDecimalWhere you see it
7F127largest signed 8-bit value
80128top bit of a byte; −128 as a signed byte
FF255largest byte; one color channel in #RRGGBB
100256values one byte can hold
4001,0241 KiB
FFFF65,535largest unsigned 16-bit value
7FFFFFFF2,147,483,647largest signed 32-bit integer
FFFFFFFF4,294,967,295largest unsigned 32-bit integer; −1 as a signed 32-bit value

Memory sizes follow the same powers of two: 400 hex is 1,024 bytes, the binary kilobyte. Our MB to GB converter explains why storage makers count in 1,000s while Windows counts in 1,024s, and the bandwidth calculator handles bits versus bytes for network speeds.

Signed numbers, 0x prefixes and hex colors

The same bit pattern can mean two numbers: FF is 255 unsigned but −1 as a signed 8-bit value, because two’s complement treats a set top bit as negative. The converter shows both, and the signed width option lets you read a value as 8, 16, 32 or 64 bits.

  • 0x marks a hex literal in C, C++, Java, JavaScript and Python, so 0x1F is 31. 0b marks binary and 0o octal in JavaScript and Python.
  • Hex colors such as #FF8800 are three bytes: FF = 255 red, 88 = 136 green, 00 = 0 blue.
  • Negative decimal input such as −1 shows its two’s complement pattern, for example FFFF in 16 bits.
  • Gray code changes only one bit between neighboring numbers, which is why rotary encoders use it.

JavaScript numbers lose precision above 2⁵³ − 1 (9,007,199,254,740,991). This converter uses BigInt arithmetic instead, so a 40-digit hex value converts exactly.

Frequently Asked Questions

How do you convert hex to decimal?

Multiply each hex digit by 16 to the power of its position, counting from 0 at the right, and add the products. A to F count as 10 to 15, so 2F = 2 × 16 + 15 = 47.

What is FF in decimal?

FF in hex is 255 in decimal: 15 × 16 + 15 = 255. It is the largest value one byte can store, and as a signed 8-bit number the same pattern means −1.

What does 0x mean in front of a number?

0x is a prefix that marks a hexadecimal number in programming languages such as C, Java, JavaScript and Python. 0x10 is 16, not ten.

How do you convert decimal to hexadecimal?

Divide the number by 16 repeatedly and note each remainder until the quotient is 0, then read the remainders from last to first. 255 ÷ 16 = 15 remainder 15, and 15 ÷ 16 = 0 remainder 15, so 255 is FF.

Why do computers use hexadecimal?

Hexadecimal is a short way to write binary: one hex digit stands for exactly four bits and two digits for one byte. It is easier to read than long strings of 0s and 1s and converts to binary without any arithmetic.

What is 0xFFFFFFFF in decimal?

0xFFFFFFFF is 4,294,967,295, the largest unsigned 32-bit number. Read as a signed 32-bit integer, the same bits mean −1.

Sources and further reading