Developer tools

Number Base Converter

Number Base Converter

Convert whole numbers between binary, octal, decimal, hex and any base 2–36, with two's complement.

About this tool

About Number Base Converter

Type a number into any row, binary, octal, decimal, hexadecimal, base 32, base 36 or a custom base from 2 to 36, and every other row updates as you type. There is no From or To to set: edit whichever representation you have. The converter uses arbitrary-precision integers, so a 128-bit hash, a 64-bit ID or a 300-digit number converts exactly, without the rounding you get from calculators that use floating point. It understands 0x, 0b and 0o prefixes, a minus sign, and digit separators such as underscores, spaces and commas. Invalid digits are reported with their position. For low-level work, the Two's complement panel shows the bit pattern of a value at 8, 16, 32, 64 or 128 bits, or the smallest width that fits, and reads that pattern back as signed and unsigned. Turn on Group digits for readable nibbles and thousands, and Uppercase letters for hex.

Built and maintained by Abhi JainUpdated

How to Convert Between Number Bases

  1. 1

    Type in any base

    Enter the number in the row for its base, such as Binary, Decimal or Hexadecimal. Use Custom base for anything from 2 to 36.

  2. 2

    Copy the result

    Every other row updates instantly. Copy a value with its button, and turn on Group digits or Uppercase letters if you like.

  3. 3

    Check the bits

    For negative numbers or bit patterns, choose a Bit width in the Two's complement panel to see the pattern and its signed and unsigned values.

Number Base Converter: questions and answers

How do you convert a number from one base to another?

Multiply each digit by the base raised to its position and add them up to get the value (for example 1011 in base 2 is 8 + 0 + 2 + 1 = 11). Then divide that value by the new base repeatedly; the remainders, read from last to first, are the digits in the new base.

What is two's complement?

It is how computers store negative integers. In n bits, a negative number x is stored as 2^n + x, so -1 in 8 bits is 11111111 and -128 is 10000000. The top bit acts as the sign, and addition works the same for signed and unsigned values.

Why does base 36 stop at Z?

Base 36 uses the 10 digits plus the 26 letters A to Z, which is every alphanumeric character. It is used for short IDs and URL shorteners. Bases above 36 need extra symbols and have no single standard.

Can it convert fractions?

No, it converts whole numbers only, exactly. Fractions such as 0.1 often have no finite representation in binary, so any result would be rounded. Remove the fractional part first.

How large can the numbers be?

There is no fixed limit. The converter uses BigInt, so numbers with hundreds of digits convert exactly. Very long inputs may take a moment.