Hexadecimal Converter - Hex to Decimal, Binary, Octal

Free hexadecimal converter for programmers. Convert hex to decimal, binary, and octal instantly. Supports color codes, memory addresses, and more.

Results

Calculated
Result
—

Frequently Asked Questions

How do I convert hex to decimal by hand?
Multiply each digit by 16 raised to its position and add the results. For example, 1F is 1 × 16 + 15 = 31.
Why do colour codes use hex?
Each colour channel runs from 0 to 255, which is exactly two hex digits (00 to FF), so six digits describe red, green and blue compactly.
Is the hex output upper or lower case?
Upper case, for example 0xFF. Input in either case is accepted.
What is the largest number I can convert?
There is no fixed limit in the arithmetic, so very long values work. Practical limits come from your browser's memory and the length you can paste.
What does the 0x prefix mean?
The 0x prefix is a C-language convention that marks a literal as hexadecimal. So 0x2F means the hex number 2F, equal to 47 in decimal. This converter accepts values with or without the prefix.
How do I convert decimal to hexadecimal?
Divide the decimal number by 16 and record the remainder. Divide the quotient again by 16 and record that remainder. Repeat until the quotient reaches 0, then read the remainders from bottom to top. Any remainder of 10–15 becomes A–F. For example, 47 ÷ 16 = 2 remainder 15 (F), then 2 ÷ 16 = 0 remainder 2, giving 2F.
How many hex digits fit in one byte?
Exactly two. A byte holds 8 bits and each hex digit represents 4 bits, so two digits cover the full 0–255 range of a byte. That is why colour codes and ASCII values are always written as two-digit hex pairs such as FF or 41.
Can this converter handle negative numbers?
No. The converter works with unsigned (non-negative) whole numbers only. Two's complement representation for signed integers is not calculated here. For negative values, negate the number, convert the absolute value, and apply two's complement rules for your chosen bit width manually.

What the Hex Converter does and when to use it

This converter translates a whole number between hexadecimal, decimal, binary and octal at once. Pick the base of the number you are entering, type it, and the page shows the same value in all four systems, the number of bits it needs, and the bytes those bits fill. It is useful for programmers reading memory addresses, web designers decoding colour codes, electronics students working with registers, and anyone checking a manual conversion.

Hexadecimal is popular because each hex digit equals exactly four binary digits, so long binary strings shrink to a quarter of the length. Two hex digits describe one byte, which is why colours, MAC addresses and character codes are so often written in hex.

Formula and method

Hexadecimal uses sixteen symbols: 0 to 9 and A to F, where A is 10 and F is 15. Each digit position is worth a power of 16, so the number 41 in hex is 4 × 16 + 1 = 65 in decimal. To convert decimal to hex, divide repeatedly by 16 and read the remainders backwards. To convert hex to binary, replace each digit with its four-bit group.

The tool accepts optional prefixes 0x, 0b and 0o, ignores spaces, underscores and commas, and works with very large integers because it uses arbitrary-precision arithmetic. Only unsigned whole numbers are supported.

  • Hex digit one of 0-9, A-F, worth 4 bits.
  • Place value 16 raised to the digit's position, counted from 0 on the right.
  • Bits required the length of the binary form with no leading zeros.
  • Bytes bits divided by 8, rounded up.

Hex digit reference

Hexadecimal uses sixteen digits. Each digit equals exactly four binary bits (one nibble), so two hex digits pack one full byte (8 bits).

Hex DigitDecimalBinary (4-bit)
000000
110001
220010
330011
440100
550101
660110
770111
881000
991001
A101010
B111011
C121100
D131101
E141110
F151111

Powers of 16

Each digit position in a hex number is worth a power of 16, counting from zero at the right. Knowing these values lets you expand any hex number into its decimal sum by hand.

PowerValueDigit position (from right)
16&sup0;11st (units)
16¹162nd
16²2563rd
16³4,0964th
16⁴65,5365th

Worked example

Convert the hexadecimal number 41 into other bases.

  1. Decimal: 4 × 16 + 1 = 65.
  2. Binary: 65 = 64 + 1, so 1000001 (seven bits).
  3. Octal: group the binary from the right as 001 000 001, giving 101.
  4. Bytes: 7 bits need 1 byte.

The converter shows 0x41, 65, 1000001 and 101, reports 7 bits (1 byte), and notes that 65 is the printable ASCII character A. Entering six hex digits such as 1A2B3C gives decimal 1,715,004, needs 21 bits (3 bytes), and is recognised as a possible CSS colour, #1A2B3C, with red 1A, green 2B and blue 3C.

A second example using hex 2F: F is 15, so 2F = 2 × 16 + 15 = 32 + 15 = 47 decimal. Expanding in binary: 47 = 32 + 8 + 4 + 2 + 1, which is 101111 (6 bits, 1 byte). Grouped as octal: 101 111 gives 57. The converter confirms: 0x2F, 47, 101111 (6 bits, 1 byte), octal 57.

Common mistakes and how to interpret the result

  • Choosing the wrong input type. The digits 10 mean sixteen in hexadecimal, ten in decimal, and two in binary. Always confirm the selected base before converting.
  • Expecting negative numbers or fractions. Two's complement and floating-point representations are not handled; the converter accepts only non-negative whole numbers.
  • Reading bit counts as field widths. Leading zeros are dropped, so 0x0041 still reports 7 bits even though it might be stored in 16 bits.
  • Mixing up look-alike characters. The letter O is not a hex digit, so use the digit 0, and letters beyond F are rejected as invalid input.

Related calculators