Number Base Converter

This number base converter moves a number between any two bases from 2 to 36, and always shows binary, octal, decimal, and hexadecimal side by side. It works on integers of any length and on fractions.

Updated
Runs in your browser. Your data is not uploaded.

Whole numbers of any length. Fractions (0.1) and a minus sign work too. Prefixes such as 0x, 0b, and 0o are accepted.

Result
–
Binary (base 2)
–
Octal (base 8)
–
Decimal (base 10)
–
Hexadecimal (base 16)
–

How to use the Number Base Converter

  1. Type the Number. Prefixes such as 0x, 0b, and 0o are accepted, and so are spaces or underscores between digits.
  2. Choose the base it is written in under From, and the base you want under To.
  3. Read the result, plus binary, octal, decimal, and hex. Turn on Two's complement to see a negative number as a fixed-width bit pattern.

How it works

To read a number, each digit is multiplied by the base raised to its position, counting from 0 on the right:

7f (base 16) = 7 × 16¹ + 15 × 16⁰ = 127

To write a number in another base, it is divided by that base again and again; the remainders, read from last to first, are the digits. Fractions are multiplied by the base instead, and each whole part that comes out is the next digit. If a remainder repeats, the digits repeat forever, and the tool puts the repeating block in parentheses: 0.1 in decimal is 0.0(0011) in binary.

Integers use JavaScript BigInt, so a 100-digit number converts without rounding.

Examples

  • 255 (decimal) = 11111111 (binary) = 377 (octal) = ff (hex).
  • 7f (hex) = 127 (decimal).
  • 0.1 (decimal) = 0.0(0011) (binary), a repeating fraction.
  • −1 as 8-bit two's complement = 11111111.

Common numbers in four bases

DecimalBinaryOctalHex
0000
1111
21022
711177
81000108
10101012a
15111117f
16100002010
321000004020
64100000010040
100110010014464
12711111111777f
25511111111377ff
256100000000400100
1024100000000002000400

Which base is used where

Computers store everything in binary (base 2). Hexadecimal (base 16) is a compact way to write binary, since one hex digit is exactly four bits; it shows up in colors (#ff8800), memory addresses, and byte dumps. Octal (base 8) survives mainly in Unix file permissions such as 755. Base 36 uses all digits and letters and is sometimes used for short IDs.

Limitations

  • Fractions are written to 20 digits. A fraction that doesn't end or repeat within 20 digits is cut off and marked with "…".
  • Two's complement is shown only for whole numbers that fit in the chosen width.
  • Letters are case-insensitive, so a base-36 number can't use case to carry meaning.

Frequently asked questions

How do I convert decimal to hexadecimal?

Divide by 16 repeatedly and write the remainders from last to first, using a-f for 10 to 15. For example, 255 gives remainders 15 and 15, so it is ff.

What bases does this converter support?

Every base from 2 to 36. Bases above 10 use the letters a to z as digits.

Can it convert very large numbers?

Yes. Whole numbers are handled with BigInt, so there is no size limit beyond your browser's memory.

What is two's complement?

The way computers store negative integers: the bits of the positive value are inverted and 1 is added. In 8 bits, −1 is 11111111 and −128 is 10000000.

Often used together with the Number Base Converter.