Hex to Decimal Converter

Type a hex value and watch it break into place value arithmetic, one digit at a time. Every column is shown with its own power of 16, so the total is something you follow rather than trust.

Hexadecimal to decimal conversion workspace

Digits 0 to 9 and letters A to F. A leading 0x is fine.

Try:

Decimal, base 10

Type a hex value to see its decimal equivalent

Place value ledger

Each hex digit gets its own row here, multiplied by the power of 16 sitting under its column.

Binary, base 2
Waiting

Grouped in fours, since one hex digit is exactly four bits.

Octal, base 8
Waiting

Still turns up in Unix file permissions.

Bits needed
Waiting

Smallest standard width appears once a value is entered.

Signed reading
Waiting

Reads the same bits as a two's complement signed integer.

Every hex digit is worth sixteen of the one to its right

Base 16 works the same way base 10 does. Move one column left and the weight multiplies. In decimal the multiplier is ten, so 407 reads as four hundreds, no tens, seven ones. In hex the multiplier is sixteen, so 1A7 reads as one 256, ten 16s, seven 1s, which lands on 423.

The awkward part is the letters. A through F carry the values ten through fifteen, because base 16 needs sixteen single characters and the digits run out at nine. Once you read A as ten and F as fifteen, the arithmetic stops being unusual.

What each hex digit is worth
HexDecimalBinaryHexDecimalBinary
000000881000
110001991001
220010A101010
330011B111011
440100C121100
550101D131101
660110E141110
770111F151111

The binary column is why hex stuck around. One hex digit maps onto exactly four bits with no remainder, so a byte is always two hex characters and never one and a bit.

Reading the ledger instead of trusting the total

Most converters hand back a number and nothing else. When the number looks wrong, you have no way to tell whether you mistyped a digit or misread the base.

The ledger under the result breaks the value apart column by column. Type 3E8 and you get three rows. The 3 sitting in the 162 column contributes 768. The E, worth 14, sits in the 161 column and contributes 224. The 8 in the ones column contributes 8. Add them and you have 1000.

Rows for zero digits stay dim rather than disappearing, because a missing column is the most common transcription error there is. Dropping a zero from 0x1000 divides the value by sixteen, and a dim row in the right place makes the mistake visible.

Where a lot of hex converters quietly go wrong

Here is the failure worth knowing about, because it is silent and it produces a plausible looking answer.

JavaScript numbers are 64 bit floating point. Whole numbers stay exact up to 9007199254740991, which is 1FFFFFFFFFFFFF, fourteen hex digits. Past that point the format runs out of room in the mantissa and starts rounding to the nearest representable value.

Ask a browser for parseInt("FFFFFFFFFFFFFFFF", 16) and it answers 18446744073709552000. The correct value is 18446744073709551615. The last four digits are fabricated by rounding, and nothing in the output warns you.

This page runs on BigInt instead, which carries arbitrary precision. A 64 bit maximum, a 128 bit UUID or a 256 bit hash all convert exactly, no matter how many digits you paste in.

Sixty four bit values are not exotic. Database identifiers, file offsets, memory addresses on any modern machine and Unix timestamps in nanoseconds all live above the safe integer limit. Anyone who has pasted a hex snowflake ID into a converter and got a number ending in zeros has hit this.

The same bits, two different numbers

Hex describes a bit pattern. Whether that pattern means a large positive number or a small negative one depends on how the surrounding code declares the variable, and hex alone does not record the decision.

Take FFFFFFFF. Read as an unsigned 32 bit integer it is 4294967295. Read as a signed 32 bit integer it is negative one, because the top bit is set and two's complement treats a set high bit as the sign. Both readings are correct. They answer different questions about the same four bytes.

The signed panel switches between 8, 16, 32 and 64 bit widths so you get both readings side by side. Width matters as much as the bits do. FF is 255 unsigned, negative one as a signed byte, and a plain 255 at any wider width, because the high bit of a 16 bit word is nowhere near it.

This is where error codes trip people up. A function returning 0xFFFFFFFE has almost certainly returned negative two, not four billion.

Who ends up needing this

Web developers pulling colour channels apart. A hex colour is three bytes stacked together, so #FF5733 splits into FF, 57 and 33, giving red 255, green 87, blue 51. Converting the whole string at once gives 16734003, which is the packed integer some graphics APIs want and no use at all for reading channel values. For colours specifically, the Hex to RGB Converter does the splitting for you.

Embedded and systems work brings different traffic. Register offsets, memory addresses, opcode values and status flags arrive in hex from datasheets and debuggers, then need to be decimal for arithmetic. Bit level work usually wants Hex to Binary rather than decimal, and the Bitwise Calculator covers masking and shifting.

Students working through number systems tend to want the reverse trip as well. Decimal to Hex runs the division and remainder method in the other direction. Binary to Decimal and Octal to Decimal use identical place value arithmetic with a different multiplier, and the All Number Converter shows every base at once when the target is a comparison rather than a single answer.

What this converter will not do

Integers only. Hex fractions like 1.8p3 and IEEE 754 hex float literals are rejected rather than guessed at, because the bit layout of a float is a separate problem from place value arithmetic.

No negative input. A leading minus sign is not accepted, since negative values in hex are normally expressed as two's complement bit patterns rather than signed text. Use the signed panel to read a pattern as negative.

Prefixes are tolerated, not required. A leading 0x, spaces, commas and _ separators are stripped before parsing, so pasting 0xDEAD_BEEF straight out of source works. Anything left that is not a hex digit is named in the message under the input rather than being silently dropped, because a converter that ignores a stray character will happily return the wrong number.

Everything runs inside the page. No value is sent to a server, nothing is stored between visits, and closing the tab ends it.

Hex to decimal questions worth answering

The parts of base 16 conversion that catch people out.

How do I convert hex to decimal by hand?

Number the columns from the right starting at zero. Multiply each digit by 16 raised to its column number, treating A as 10 through F as 15, then add the results. For 2F1 that gives 2 times 256, plus 15 times 16, plus 1, which totals 753. The ledger on this page shows the same three lines for any value you type.

Why does my browser console give a different answer for long hex values?

parseInt returns a floating point number, which stays exact only up to 9007199254740991. Above that limit the result rounds to the nearest representable value, so a 16 digit hex input comes back with fabricated trailing digits. This page uses BigInt, which stays exact at any length. In your own code, use BigInt("0x" + hex) rather than parseInt when the value might exceed 53 bits.

Is FFFFFFFF equal to 4294967295 or negative one?

Both, depending on the type. As an unsigned 32 bit integer it is 4294967295. As a signed 32 bit integer it is negative one, because two's complement reads a set high bit as a sign. Hex records the bit pattern and not the type, so the surrounding code decides. The signed panel shows both readings at 8, 16, 32 and 64 bits.

Does capitalisation change the value?

No. Hex is case insensitive, so ff, FF and Ff all convert to 255. Uppercase is the common convention in datasheets and memory dumps, lowercase is more usual in CSS colours and hashes. The input normalises to uppercase for readability without altering the arithmetic.

Why is hex used instead of decimal in programming?

One hex digit covers exactly four bits, so a byte is always two hex characters and a 32 bit word is always eight. Decimal has no clean relationship to bit boundaries, which makes 255 look unremarkable while FF sits visibly at the edge of a byte. Hex also keeps large binary numbers short without hiding their bit structure.

Can I convert a hex colour code here?

You can, but read the result carefully. Converting FF5733 as one value returns 16734003, the packed integer form. Colour channels need each pair converted separately, so FF gives 255 red, 57 gives 87 green and 33 gives 51 blue. The Hex to RGB Converter handles the split in one step.