CONVERTER

Hex to Decimal Converter (and Decimal to Hex)

Convert hex to decimal or decimal to hex, see the value as a signed 8, 16, 32 or 64-bit integer with its bytes in both orders, follow the working, and print the 00–FF chart.

Edit either field and the other follows. Upper or lower case, a 0x or # prefix, spaces, underscores and colon or hyphen separators (as in a MAC address) are accepted. Whole numbers only.

About this tool

Paste a hex value and get its decimal equivalent, or type a decimal number and get hex back. Next to the two fields, the tool lists the binary bits in groups of four, reads the value as a signed integer of the width you choose, splits it into bytes in both big-endian and little-endian order, and writes out the arithmetic. It works on whole numbers of any length thanks to JavaScript BigInt, so 64-bit hashes and long IDs convert without rounding. Need to turn a string of text into hex byte codes instead? That is what the Text to Binary and Hex converter does. This page treats the input as one number.

How to convert hex to decimal here

  1. Enter the hex value in the Hexadecimal field. 0x1F, 1f, #1F and 1F all mean the same number.
  2. The decimal result appears straight away. Type in the Decimal field to go the other way.
  3. Choose 8, 16, 32 or 64 bits to match the variable or register you are reading. The box below shows the signed value and the byte order for that width.
  4. Use the step-by-step box to check your own hand calculation.

Why one hex digit equals four bits

Hexadecimal is base 16, and 16 = 24. Four bits have exactly 16 possible patterns, from 0000 to 1111, and hex has exactly 16 digits, 0 to 9 then A (10) to F (15). So every hex digit maps to one fixed group of four bits with no carrying between groups, and a byte (eight bits) is always two hex digits. That is the whole reason hex is so common in computing: it is a compact way to write binary that you can still convert in your head. The default value shows it: FF9C is 1111 1111 1001 1100, one group per digit.

Worked example: FF9C to decimal

Each place in a hex number is worth a power of 16, counting from 0 on the right. Multiply each digit’s value by its place and add:

DigitValuePlaceProduct
F15163 = 4,09661,440
F15162 = 2563,840
99161 = 16144
C12160 = 112

The sum is 61,440 + 3,840 + 144 + 12 = 65,436. Going back from decimal to hex, divide by 16 and keep the remainders: 65,436 ÷ 16 = 4,089 remainder 12 (C); 4,089 ÷ 16 = 255 remainder 9 (9); 255 ÷ 16 = 15 remainder 15 (F); 15 ÷ 16 = 0 remainder 15 (F). Reading the remainders from last to first spells FF9C.

If those two bytes hold a signed 16-bit integer, the answer is different. A 16-bit pattern whose top bit is set stands for its unsigned value minus 65,536, so FF9C read as signed is 65,436 − 65,536 = -100. The same bits, two meanings: the program reading them decides which, so pick the width that matches your data type.

Where you meet hex numbers

Byte order

Byte order only matters once a number is stored in memory or a file as several bytes. Big-endian puts the most significant byte first, so the 16-bit value FF9C is stored as FF 9C. Little-endian, the order x86 processors use, stores the same value as 9C FF. If a hex dump shows 9C FF and you convert it as written, you get 40,191 instead of 65,436. Reverse the byte pairs (not the single digits) first.

Common mistakes

Sources: MDN on CSS hex colors, the Unicode UTF and BOM FAQ for the code point range, and the IEEE EUI guidelines for MAC address notation.

Frequently asked questions

What is FF in decimal?

FF is 255. F is 15, so FF = 15 × 16 + 15 = 255, the largest value one byte can hold. Read as a signed 8-bit integer the same bits mean -1. In a web color, FF is a channel at full strength, which is why #FFFFFF is white.

How do you convert decimal to hex without a calculator?

Divide the number by 16 and note the remainder, then keep dividing each quotient by 16 until it reaches 0. Write each remainder as a hex digit (10 is A, up to 15 is F) and read them in reverse order. For 300: 300 ÷ 16 = 18 r 12 (C), 18 ÷ 16 = 1 r 2, 1 ÷ 16 = 0 r 1, so 300 = 12C.

What does the 0x prefix mean?

The 0x prefix marks a number as hexadecimal in C, C++, Java, JavaScript, Python and many other languages, so 0x10 is read as 16 rather than ten. It is only a label: the digits after it are the actual value. Other notations you may meet are a trailing h, as in 1Fh, and the # sign used for colors.

How many decimal digits does a hex number have?

It varies, because 16 is not a power of 10. Each hex digit carries four bits, about 1.2 decimal digits, so decimal versions run a little longer. Two hex digits reach 255 (three decimal digits), eight hex digits reach 4,294,967,295 (ten digits), and sixteen hex digits reach 18,446,744,073,709,551,615 (twenty digits).

Can hexadecimal numbers be negative?

Yes. Written with a minus sign, -1A is simply -26. In computer memory there is no minus sign, so negative integers are stored in two's complement: -26 as a 16-bit value is FFE6, because 65,536 - 26 = 65,510 = FFE6. Type -26 in the decimal field to see the pattern for any width.

Is hex the same as base 16?

Yes. Hexadecimal, hex and base 16 all name the same number system with sixteen digits, 0 to 9 and A to F. The letters can be upper or lower case; ff and FF are equal. Base 16 is popular because it lines up exactly with bytes, two digits per byte, unlike base 10.