Hex to Decimal Converter

Multiply each hex digit by 16 raised to its position, counted from the right, and add the results: 2F3 = 2 × 256 + 15 × 16 + 3 = 755. The converter does this for a value or a list, with a 0x prefix or without, and shows the signed reading at 8, 16, 32 and 64 bits. Everything is calculated in your browser.

Hex to decimal
3 hex digits · 10 bits
755 (with thousands separators)
Accepts 0x, a trailing h, underscores and lowercase · your input stays in this browser

Step-by-step conversion

(2F3)₁₆ = (2 × 16²) + (15 × 16¹) + (3 × 16⁰)
= (2 × 256) + (15 × 16) + (3 × 1)
= 512 + 240 + 3
= 755
Place values for 2F3
DigitValueWeightProduct
2216^2 = 256512
F1516^1 = 16240
3316^0 = 13

As a signed two's complement integer: 16-bit 755 · 32-bit 755 · 64-bit 755

How to convert hex to decimal by hand

Hexadecimal is a positional system with base 16, so each digit has a weight that is a power of 16, counting from the right. The rightmost digit is multiplied by 16^0, which is 1. The next is multiplied by 16^1 = 16, then 16^2 = 256, then 16^3 = 4,096, and so on. Multiply every digit by its weight, add the products, and the sum is the decimal value. Digits A to F count as 10 to 15.

Place values of 2F32F3 is 2 times 16 to the 2, plus F times 16 to the 1, plus 3 times 16 to the 0, which is 755.16^2 = 25622 × 25651216^1 = 16F15 × 1624016^0 = 133 × 13Sum: 755
2F3 = 512 + 240 + 3 = 755. The rightmost digit has weight 16^0 = 1; each step left multiplies the weight by 16.

The weights grow quickly, which is why a few of them are worth knowing by heart. Each extra digit multiplies the range by 16, and every two digits make a byte, so 16^2 = 256 is the number of values in a byte.

Powers of 16 and the hex number each one is written as
PowerDecimalHex
16^011
16^11610
16^2256100
16^34,0961000
16^465,53610000
16^51,048,576100000
16^616,777,2161000000
16^7268,435,45610000000
16^84,294,967,296100000000

Hex digits A to F and their values

A hex digit stands for four bits. The ten decimal digits cover 0 to 9, and the letters supply the six values that would otherwise need two characters. Upper and lower case mean the same thing: b and B are both 11.

The 16 hex digits
Hex digitDecimalBinary (4 bits)
000000
110001
220010
330011
440100
550101
660110
770111
881000
991001
A101010
B111011
C121100
D131101
E141110
F151111

Worked example: 2F3 is 755

2F3 has three digits, so the weights are 256, 16 and 1. The 2 is worth 2 × 256 = 512. The F is 15, worth 15 × 16 = 240. The 3 is worth 3 × 1 = 3. Add them: 512 + 240 + 3 = 755.

2F3 in decimal, one digit at a time
DigitDigit valueWeightDigit × weight
2216^2 = 256512
F1516^1 = 16240
3316^0 = 13
Total755

There is a second way to do the same sum that needs no powers. Start with the first digit and, for each following digit, multiply the running total by 16 and add the digit. For 2F3: start at 2; 2 × 16 + 15 = 47; 47 × 16 + 3 = 755. Programs use this form because it handles any length with one multiplication per digit, and it is easier on paper once the number passes four digits.

A longer example: 1D2A3FB is 30,581,755

With seven digits the leftmost weight is 16^6 = 16,777,216. The digit D is 13, so it contributes 13 × 1,048,576 = 13,631,488. The sum of all seven products is 30,581,755.

1D2A3FB in decimal, one digit at a time
DigitDigit valueWeightDigit × weight
1116^6 = 16,777,21616,777,216
D1316^5 = 1,048,57613,631,488
2216^4 = 65,536131,072
A1016^3 = 4,09640,960
3316^2 = 256768
F1516^1 = 16240
B1116^0 = 111
Total30,581,755

A quick estimate catches slips: the leading digit times its weight gives the floor of the answer (here 16,777,216) and the leading digit plus one gives the ceiling (33,554,432). The result 30,581,755 is between them, and closer to the ceiling because the second digit D is large.

Converting through binary

Because 16 is 2^4, every hex digit is exactly four bits, and a hex number can be rewritten as binary by replacing each digit with its group of four. 2F3 becomes 0010 1111 0011, which is 1011110011 once the leading zeros are dropped. Add the weights of the ones, 512 + 128 + 64 + 32 + 16 + 2 + 1, and the result is 755 again. This route is slower for plain conversion but it is the one to use when the bits matter, for example when checking a flag register or a bit mask. The same digits as binary have their own page: hex to binary.

Checking your answer

Two cheap tests catch most arithmetic slips. The last hex digit is the remainder of the value divided by 16, so the decimal number must be odd exactly when the last hex digit is odd: 2F3 ends in 3, and 755 is odd. The second test uses the fact that 16 is one more than 15. Adding up the values of the hex digits gives a number with the same remainder modulo 15 as the full value. For 2F3 the digits give 2 + 15 + 3 = 20, which leaves 5 after dividing by 15, and 755 leaves 5 as well. For 1D2A3FB the sum is 55 and the remainder is 10; 30,581,755 also leaves 10. A mismatch means a product or a sum is wrong; a match does not prove the answer, but a wrong one passes it only about one time in fifteen.

Fractions: hex digits after a point

The weights continue below the point as 16^−1, 16^−2 and so on, which are 1/16, 1/256 and smaller. 2F.8 is 2 × 16 + 15 + 8/16 = 47.5, and 0.A is 10/16 = 0.625. Hex fractions with a short expansion are always exact in decimal, but the reverse fails: decimal 0.1 is 0.1999… in hex and repeats forever, which is the reason floating-point values such as 0.1 cannot be stored exactly. The converter on this page handles whole numbers only; floating-point hex is a separate topic, covered by hex to float.

Hex to decimal answers people look up

Some values are searched for again and again because they are the limits of common integer types or turn up in logs and source code. They are collected here, computed with the same routine as the converter above. Any other value goes into the converter above.

Common hex values in decimal
HexDecimalWhy it comes up
3351The ASCII digit 3; also 3 × 16 + 3
FF255Largest value of one byte
100256256: one more than a byte holds
3E81,000One thousand
7FFF32,767Largest signed 16-bit integer
FFFF65,535Largest unsigned 16-bit integer, and the highest TCP and UDP port number
7FFFFFFF2,147,483,647Largest signed 32-bit integer (INT_MAX)
FFFFFFFF4,294,967,295Largest unsigned 32-bit integer; −1 when read as signed

The question in the other direction, what is the hexadecimal of 23, has a short answer: 23 divided by 16 is 1 remainder 7, so decimal 23 is hex 17. Converting decimal to hex is the reverse procedure, repeated division by 16 with the remainders read from the last to the first, and has its own page: decimal to hex.

Signed hex: two's complement at 8, 16, 32 and 64 bits

Hex shows bits and does not carry a sign. Whether FF is 255 or −1 depends on the type of the value, and the type is not in the digits. Processors store signed integers in two's complement: the top bit has a negative weight. In an 8-bit value the weights are −128, 64, 32, 16, 8, 4, 2, 1. The byte FF has every bit set, so it is −128 + 127 = −1.

Sign bit in an 8-bit valueIn two's complement the top bit of a byte is worth -128 instead of +128. 7Fh is 127 unsigned and 127 signed; 80h is 128 unsigned and -128 signed; FFh is 255 unsigned and -1 signed.weight−1286432168421unsignedsigned7Fh0111111112712780h10000000128−128FFh11111111255−1
The top bit is the sign bit. In a signed byte it is worth −128, in an unsigned byte +128. The other seven bits are the same in both readings.

To read a hex value as signed by hand, first decide the width, which is the number of digits in the type and not in the number you were given (a 32-bit integer is eight hex digits, so 7F is written 0000007F). If the top bit is clear, meaning the first hex digit is 0 to 7, the value is the same as unsigned. If the first digit is 8 to F, subtract 2^bits from the unsigned value: FFFFFFFF is 4,294,967,295 − 4,294,967,296 = −1. The reverse, writing a negative number as hex, adds 2^bits: −2 as 8 bits is 256 − 2 = FE.

The same hex digits as unsigned and as two's complement at their natural width
HexWidthUnsignedSigned
7F8-bit127127
808-bit128−128
FF8-bit255−1
7FFF16-bit32,76732,767
800016-bit32,768−32,768
FFFF16-bit65,535−1
7FFFFFFF32-bit2,147,483,6472,147,483,647
8000000032-bit2,147,483,648−2,147,483,648
FFFFFFFF32-bit4,294,967,295−1

The width changes the answer for the same digits. FF as an 8-bit value is −1, but as a 16-bit value (00FF) it is 255, because the top bit of the wider type is 0. When you enter a single value in the converter, the signed readings are listed for every width that is large enough to hold the digits you typed. A leading minus sign is also accepted: −FF is −255, and in 16 bits it is stored as FF01.

Reading multi-byte values from a dump: byte order

Values copied from a memory dump, a network capture or a file header are often several bytes long, and the order of those bytes changes the number. Most desktop and mobile processors store integers little-endian: the least significant byte comes first. Network protocols and many file formats use big-endian, called network byte order, with the most significant byte first. The decimal value 755 (hex 2F3) as a 32-bit integer is F3 02 00 00 in a little-endian dump and 00 00 02 F3 in a big-endian one.

To convert, write the bytes in the order of significance first, then convert as usual. The two bytes E8 03 in little-endian are 03E8 once reversed, which is 1,000. Read in the wrong order they become E803 = 59,395. A result that is wildly off by a factor of 256 or 65,536, or that suddenly looks plausible after reversing the pairs, points at byte order. The text version of this problem is the UTF-16 byte order discussed on the hex decoder page.

Hex to decimal conversion table, 00 to FF

Every two-digit hex value, laid out as a grid: find the first digit in the left column and the second digit in the top row. The cell is the decimal value. For example, row 2 and column F is 2F = 47, the running total from the by-hand example above. The rows step by 16, so the first column is 0, 16, 32, 48 and so on.

Decimal value of the two-digit hex number whose first digit is the row and second digit the column
0123456789ABCDEF
00123456789101112131415
116171819202122232425262728293031
232333435363738394041424344454647
348495051525354555657585960616263
464656667686970717273747576777879
580818283848586878889909192939495
696979899100101102103104105106107108109110111
7112113114115116117118119120121122123124125126127
8128129130131132133134135136137138139140141142143
9144145146147148149150151152153154155156157158159
A160161162163164165166167168169170171172173174175
B176177178179180181182183184185186187188189190191
C192193194195196197198199200201202203204205206207
D208209210211212213214215216217218219220221222223
E224225226227228229230231232233234235236237238239
F240241242243244245246247248249250251252253254255

Hex to int: what fits in 8, 16, 32 and 64 bits

Converting to an int is the same arithmetic, followed by a question: does the value fit in the type? The widest hex string that fits in n bits has n / 4 digits, and the type then decides how the result is read. A string longer than the type is an overflow, which is a common cause of a conversion that returns zero, a negative number or a wrong one.

Largest hex values and ranges by bit width
BitsHex digitsLargest hexLargest unsignedSigned range
82FF255−128 to 127
164FFFF65,535−32,768 to 32,767
328FFFFFFFF4,294,967,295−2,147,483,648 to 2,147,483,647
6416FFFFFFFFFFFFFFFF18,446,744,073,709,551,615−9,223,372,036,854,775,808 to 9,223,372,036,854,775,807

JavaScript is the usual place this bites. Numbers are 64-bit floating point values, and integers are exact only up to 2^53 − 1 = 9,007,199,254,740,991, which is 1FFFFFFFFFFFFF in hex (14 digits). parseInt("FFFFFFFFFFFFFFFF", 16) returns 18446744073709552000 and not 18446744073709551615, because the low digits are lost. The converter on this page uses arbitrary-precision integers, so a 64-digit hex string is converted exactly. See Number.MAX_SAFE_INTEGER on MDN for the limit.

A quick way to size a result before converting: each hex digit adds about 1.2 decimal digits, because log10 of 16 is 1.204. Eight hex digits are at most 10 decimal digits (4,294,967,295) and sixteen are at most 20 (18,446,744,073,709,551,615). Round hex numbers are worth memorizing as sizes, since memory and address spaces are built from them.

Round hex numbers and the sizes they stand for
HexDecimalSize
10004,0964 KiB, a common memory page
1000065,53664 KiB; 65,536 values in 16 bits
1000001,048,5761 MiB
100000016,777,21616 MiB; the number of 24-bit colors
400000001,073,741,8241 GiB
1000000004,294,967,2964 GiB; the size of a 32-bit address space

Convert a list of hex values at once

Paste several values, one per line or separated by commas, spaces or semicolons, and each is converted on its own line in the same order. That covers a column copied from a spreadsheet, an array of constants from source code (0x1F, 0x2A, 0xFF) or a list of addresses. The output is one decimal number per line, so it can be pasted back into a spreadsheet or into an array literal after adding commas.

A bad entry does not stop the rest. The line for the value that failed is left empty, the message names the entry and the offending character, and the Show button jumps to the character in the input. With several values the signed readings and place-value table are not shown; enter one value to see them.

Hex to decimal in Python, JavaScript, C and the shell

Every language has a one-line conversion. The differences are in what happens to a prefix, an invalid digit and a value that is too large.

Python
int("2F3", 16)          # 755
int("0x2F3", 16)        # 755; the prefix is accepted when the base is 16
int("1D2A3FB", 16)      # 30581755; Python integers have no size limit

# signed 32-bit reading of eight hex digits
int.from_bytes(bytes.fromhex("FFFFFFFF"), "big", signed=True)   # -1

int() raises ValueError for any character outside the base, and also for a trailing h. See the Python documentation for int.

JavaScript
parseInt("2F3", 16)           // 755
Number("0x2F3")               // 755
BigInt("0x1D2A3FB")           // 30581755n, exact for any length
parseInt("2F3xyz", 16)        // 755; stops at the first invalid character
parseInt("FFFFFFFFFFFFFFFF", 16)   // 18446744073709552000: precision lost
C
#include <stdlib.h>
unsigned long v  = strtoul("2F3", NULL, 16);        /* 755 */
unsigned long long w = strtoull("FFFFFFFFFFFFFFFF", NULL, 16);  /* 18446744073709551615 */
sscanf("2F3", "%x", &x);                             /* x is unsigned int */

strtoul accepts a 0x prefix when the base is 16 and sets endptr to the first character it could not use, which is how you detect trailing junk.

Shell (Bash) and PowerShell
echo $((16#2F3))              # 755
printf '%d\n' 0x2F3           # 755

[Convert]::ToInt32("2F3", 16)          # 755
[Convert]::ToInt32("FFFFFFFF", 16)     # -1: ToInt32 reads the result as signed
[Convert]::ToUInt32("FFFFFFFF", 16)    # 4294967295

Spreadsheets and databases have the function too. Excel and Google Sheets use =HEX2DEC("2F3"). In Excel the argument is limited to 10 hex characters (40 bits), and the top bit of those 40 is treated as a sign, so FFFFFFFFFF returns −1. MySQL converts with CONV('2F3', 16, 10), which returns the text '755', or with a hex literal in arithmetic: 0x2F3 + 0.

Handling very long hex strings

Strings longer than 16 digits no longer fit in a 64-bit integer, so tools that use the native number type of their language stop being exact. Python, Java's BigInteger and JavaScript's BigInt all keep every digit. In C there is no standard type beyond unsigned long long, which tops out at 18,446,744,073,709,551,615, and the usual answer is a big-number library. Cryptographic values show the scale: a SHA-256 digest is 64 hex digits, up to 78 decimal digits, and an RSA modulus can run to 1,000 hex digits or more. They convert correctly here because the arithmetic does not round. Be careful when pasting a long value into a spreadsheet, because spreadsheets store numbers as 64-bit floating point and silently keep only 15 significant digits.

Leading zeros do not change an unsigned value, and the converter accepts them, so a fixed-width field such as 000000FF converts to 255. For signed readings the width counts, because the digits are padded to the width of the type and not to the width you typed. When the width is not known, the table of signed readings above lists each candidate and the source of the hex has to decide.

Common mistakes when converting hex to decimal

Where decimal values from hex show up

Hex is what tools print; decimal is what people compare against. Windows error codes are a typical case. HRESULT 0x80070005 is E_ACCESSDENIED. As an unsigned number it is 2,147,942,405, and as a signed 32-bit integer, which is how many logs and debuggers print it, it is −2,147,024,891. Searching for either decimal form finds the same error.

IPv4 addresses are four bytes, so C0A80001 is 192.168.0.1 when each pair is converted separately: C0 = 192, A8 = 168, 00 = 0, 01 = 1. Treating the same digits as one number gives 3,232,235,521, which is also valid as an address in many tools. Unicode code points are written in hex (U+00E9) and are 233 in decimal, and a CSS color such as FF8800 is three values, 255, 136 and 0, handled by the hex to RGB converter. If the digits you have are the bytes of a message and not a number, decode them as text instead.

Network tools print ports in hex as well. A packet capture shows the destination port of a web request as 01BB, which is 443, and a development server on 1F90 is listening on 8080. HTTP's own port 80 is 50 in hex. The same habit explains why a byte count in a file header is easier to read once converted: a length field of 00 00 10 00 is 4,096 bytes when read big-endian.

Questions about converting hex to decimal

What is 7FFFFFFF in decimal?

2,147,483,647, which is 2^31 − 1: the largest value of a signed 32-bit integer. The next hex value, 80000000, is 2,147,483,648 unsigned and −2,147,483,648 as a signed 32-bit integer.

What is 33 hex in decimal?

51: 3 × 16 + 3. As text the byte 33 is the digit character 3, so a hex string made of 33 pairs can be a string of digits.

Why is FFFFFFFF sometimes −1?

Hex does not say whether a value is signed. Read as an unsigned 32-bit number FFFFFFFF is 4,294,967,295. Read as a signed 32-bit number, whose top bit is a sign bit, the same 32 ones mean −1. The type in the program or file format decides which one is right.

Can you convert hex to decimal without a calculator?

Yes, for short values. Write the digits with their weights (1, 16, 256, 4096 from the right), multiply each digit by its weight and add. For three digits the arithmetic is small: 2F3 is 512 + 240 + 3. Memorizing 16, 256 and 4,096 makes four-digit values quick.

Does the converter handle 0x prefixes and lowercase?

Yes. 0x2f3, 2F3, 2f3 and 2F3h all give 755, and underscores are ignored, so 0xFFFF_FFFF works. A minus sign in front gives a negative result. Any character outside 0-9 and A-F is reported with its position.