Number Base Converter: Binary, Decimal, Hex, Octal

Convert whole numbers between binary, octal, decimal, hex and any base from 2 to 36, with the working shown.

Enter your number

Input is:

Converted values

Binary (2) ...
Octal (8) ...
Decimal (10) ...
Hex (16) ...

Result in custom base
...
Show the steps

How to use the number base converter

  1. Choose the base your number is written in with From base, or press the Binary, Octal, Decimal or Hex button.
  2. Type the Number. Spaces, commas and underscores are ignored, a leading minus sign is kept, and the prefixes 0x, 0b, 0o and # are understood. A prefix switches From base for you and says so.
  3. Read Binary (2), Octal (8), Decimal (10) and Hex (16) at once, plus any Custom base from 2 to 36. Press Copy beside a result, or tick Lowercase letters for output like ff.
  4. Open Show the steps for the digit-by-digit sum and the repeated division.

How base conversion works

In base b each digit is worth its value times b raised to its position, counting from 0 on the right. Adding those products gives the decimal value. Going the other way, you divide by the target base again and again and read the remainders from last to first. Digits above 9 are letters, A for 10 up to Z for 35. The tool does the arithmetic with JavaScript BigInt integers, so nothing is rounded however long the number is. See the positional notation article for the method.

Related tools: the binary and text converter turns words into bits, the IP subnet calculator works with binary masks, and the color picker turns hex codes into RGB.

Worked example

The page opens on 255 in base 10. It shows Binary 11111111, Octal 377, Decimal 255 and Hex FF, with the custom base set to 32 giving 7V. That last result is 7 x 32 + 31, because V stands for 31. The size line reads 8 bits (1 byte). In the steps, dividing 255 by 2 eight times leaves the remainder 1 each time, which spells 11111111.

Limits and edge cases

Frequently asked questions

How do I convert decimal to binary step by step?

Divide the number by 2 and write down the remainder, then divide the quotient by 2 again, and repeat until the quotient is 0. Read the remainders from last to first. For 255 the remainder is 1 every time, eight times, so the binary is 11111111. Open Show the steps to see every division.

How do I convert hex to decimal?

Multiply each hex digit by 16 raised to its position, counting from 0 on the right, and add the results. For FF that is 15 x 16 + 15 = 255. Letters stand for numbers: A is 10, B is 11, C is 12, D is 13, E is 14 and F is 15.

How large a number can this converter handle?

It uses arbitrary-precision integers, so 64-bit values and longer are exact, up to 5,000 digits. FFFFFFFFFFFFFFFF in hex is 18446744073709551615 in decimal, with no rounding. Fractions such as 10.5 are not supported.

Does it handle negative numbers and two's complement?

A leading minus sign is kept on every result, so -255 is -FF in hex. Results are not shown in two's complement. To find the 8-bit two's complement of a negative number, add 256 first, so -1 becomes 255, which is FF.

Why does base 32 here differ from Base32 encoding?

This tool writes the number itself in base 32 using the digits 0 to 9 and A to V. Base32 encodings such as RFC 4648 or Crockford turn bytes into text with their own alphabets, so their output differs from a plain base-32 number.

Sources: Positional notation, base conversion (Wikipedia), BigInt (MDN).