Hex Calculator

Convert whole numbers between hexadecimal, decimal, binary and octal.

Result

Result (base 10)
255
Decimal value
255
Export:

How base conversion works

Every number system uses a fixed set of digits: binary has 2 (0-1), octal has 8 (0-7), decimal has 10 (0-9), and hexadecimal has 16 (0-9 then A-F, where A is 10 and F is 15). The base sets the place value of each digit.

Conversion happens in two steps. The calculator first reads your input in its source base to find the plain decimal value, then re-expresses that value in the target base. Decimal acts as the common hub between any two systems.

Reading the output

The main result is your number rewritten in the target base, with hexadecimal letters shown in uppercase. The decimal equivalent is always displayed too, so you can verify the value regardless of which bases you picked.

For example FF in hexadecimal is 255 in decimal, 377 in octal, and 11111111 in binary. All four spellings represent the exact same quantity.

Where bases are used

Different bases are convenient in different technical settings.

  • Hexadecimal is compact for memory addresses and color codes like #FF8800.
  • Binary mirrors how hardware stores data as on/off bits.
  • Octal groups bits in threes and appears in Unix file permissions.
  • Each hex digit maps to exactly four binary digits, which makes converting between the two quick.

Common mistakes

Use only digits that are valid for the source base. A 2 is not a binary digit and a G is not a hex digit, so entering them produces an error. Double-check that the From base matches how your value is actually written.

This tool handles whole numbers, not fractional or decimal-point values. Leading or trailing spaces are trimmed, but a stray invalid character anywhere in the value will be rejected.

Formula

decimal = parseInt(value, fromBase); output = decimal in toBase