Skip to content
Aarrange

Number Base Converter

Paste numbers in any base, one per line. Get them in binary, octal, decimal, hex or any base up to 36, with the steps. Nothing leaves your browser.

Also: Hex to Dec, Dec to Hex, Bin to Dec, Dec to Bin, Hex to Bin, Bin to Hex

0
Numbers
0
Max bits
0
Errors
Input
Tab types a tab. Press Escape, then Tab, to leave the editor.
Result
The result shows here as you type.Try , or .
On this page

About Number Base Converter

Updated

Number Base Converter turns numbers from one base into another: binary, octal, decimal, hex, or any base from 2 to 36. Paste one number or a whole list. Each line is converted, and a line that is wrong is marked at the exact digit, with what to do about it.

From starts on Auto: 0x means hex, 0b binary and 0o octal. So a list copied from code, with numbers in different bases, works as it is. The answers are exact at any size, and Steps shows the math for each number.

The same tool, set up for other bases: Hex to Decimal, Decimal to Hex, Binary to Decimal, Decimal to Binary, Hex to Binary, Binary to Hex.

How to use it

  1. Paste numbers, one per line, or load a file. Commas, tabs and semicolons also split a line, so a column from a spreadsheet works.
  2. Check From and To, next to Convert. On a phone they are under More.
  3. Press Convert (Alt C). Results shows every number in the To base and in decimal, hex, binary and octal. Output shows only the answers, line for line, for Copy and Download.
  4. Open Steps to see the math for one number, the way you would do it on paper.
  5. Swap (Alt S) puts the answers in the editor and turns From and To around, so you can check the way back.
  6. In Options: Signed for two's complement, Groups for 1111 0000 or 4,294,967,295, Prefix for 0x, 0b or 0o, and how many digits a fraction gets.

The common bases

Bases
Base  Name         Digits            Prefix   255 is
   2  Binary       0 1               0b       11111111
   8  Octal        0 to 7            0o       377
  10  Decimal      0 to 9                     255
  16  Hex          0 to 9, A to F    0x, #    FF
  36  Base 36      0 to 9, A to Z             73

Binary is how computers store numbers. Hex writes the same bits in a quarter of the space, which is why memory addresses, colors and error codes are in hex. Octal is used for Unix file permissions: 755 is 111 101 101, read, write and run.

How a conversion works

Every base works the same way: a digit counts its value times a power of the base. To read hex 7DE:

Hex to decimal
7 × 16² = 7 × 256 = 1792
D × 16¹ = 13 × 16 =  208
E × 16⁰ = 14 × 1  =   14
                    -----
                     2014

To write 2014 in hex, divide by 16 and keep the remainders. Read them from the bottom up:

Decimal to hex
2014 ÷ 16 = 125  remainder 14 (E)
 125 ÷ 16 =   7  remainder 13 (D)
   7 ÷ 16 =   0  remainder  7
                 → 7DE

Negative numbers and two's complement

A computer stores a whole number in a fixed number of bits: 8, 16, 32 or 64. To store negative numbers too, the first bit counts as minus. In 8 bits it counts as -128, so 11111111 is -128 + 127 = -1. This is two's complement.

Set Signed in Options to read and write numbers this way. The Result header then shows the width, so you never forget it is on.

Signed: 8-bit
Decimal   Binary     Hex
    127   01111111   7F
      1   00000001   01
      0   00000000   00
     -1   11111111   FF
     -5   11111011   FB
   -128   10000000   80

To write -5 by hand: write 5 in 8 bits (00000101), flip every bit (11111010), then add 1 (11111011). Steps shows this for any number. With Signed off, a negative number keeps its minus sign: -5 is -101 in binary.

Exact for big numbers

JavaScript numbers hold 53 bits. Past that, a converter built on them rounds: FFFFFFFFFFFFFFFF comes out as 18446744073709552000. The right answer is 18446744073709551615. This tool uses BigInt, so a 64-bit ID, a 128-bit hash or a number with a million digits is exact to the last digit.

Common errors

Scientific notation

A spreadsheet or a log can write one million as 1e6. In Auto, 1e6 with no sign has only hex digits, so the tool reads it as hex 1E6 (486 in decimal) and warns that it may mean one million. With a sign after the e, as in 1e-6 or 1e+6, it is not a number in any base, so the tool stops:

Invalid
1e-6
Scientific notation is not read. Write 1e-6 in full, with all its digits.
Fixed
0.000001

The letter O for a zero

Typed by hand, a capital O and a zero look the same. The tool names the letter, so you know what to type.

Invalid
12O4
The letter O is not a digit. Type the digit 0 (zero) in its place.
Fixed
1204

Two numbers on one line

Spaces inside a number are digit groups: 1111 0000 is one number. When the groups are not the same size, the tool still reads one number but marks the line, because it may be a list.

Warning
FF 1A 7
Read as one number, FF1A7. If these are separate numbers, put each on
its own line or split them with commas.
Fixed
FF, 1A, 7

Most converters glue two lines into one number with no warning: 1F on one line and 2A on the next become 1F2A, which is 7978.

A number too big for its bits

With Signed set to a width, every number must fit in it. The message gives the range.

Invalid
300 (Signed: 8-bit)
300 does not fit in signed 8 bits. Signed 8-bit numbers go from -128 to 127.
Pick a wider Signed setting, or set it to Off.

In code and Excel

Each pair has a one-line answer in the common languages. The examples use 255 (hex FF), 45 (binary 101101), 25 (binary 11001) and hex 3F:

In code
Pair               Python                 JavaScript                          Excel
Hex to decimal     int("ff", 16)          parseInt("ff", 16)                  =HEX2DEC("FF")
Decimal to hex     format(255, "x")       (255).toString(16)                  =DEC2HEX(255)
Binary to decimal  int("101101", 2)       parseInt("101101", 2)               =BIN2DEC("101101")
Decimal to binary  format(25, "b")        (25).toString(2)                    =DEC2BIN(25)
Hex to binary      bin(int("3f", 16))     parseInt("3f", 16).toString(2)      =HEX2BIN("3F")
Binary to hex      hex(int("101101", 2))  parseInt("101101", 2).toString(16)  =BIN2HEX("101101")

In C, strtol(s, NULL, base) reads a number in any base from 2 to 36. In Java, Long.parseLong(s, base) reads one and Long.toString(n, base) writes one. JavaScript parseInt rounds past 2^53, so use BigInt("0x" + s) for big hex. Excel works with at most 10 hex digits or 10 bits, so DEC2BIN goes only from -512 to 511 and HEX2BIN only up to 1FF. Each pair page has the details.

Number base resources

Number base FAQ

What is a number base?

The base is how many digits a number system has. Decimal, base 10, has ten: 0 to 9. Binary, base 2, has two: 0 and 1. Hex, base 16, has sixteen: 0 to 9 and A to F. In each base a digit's place sets what it counts: in decimal the places are 1, 10, 100; in binary 1, 2, 4, 8; in hex 1, 16, 256.

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

Go through decimal. To read a number, multiply each digit by its place value and add: hex 7DE is 7 × 256 + 13 × 16 + 14 = 2014. To write it in the new base, divide by that base again and again and keep the remainders, read from the bottom up.

Between binary and hex or octal there is a shortcut: each hex digit is exactly 4 bits, and each octal digit 3. Paste a number here and open Steps to see the method for that pair.

What do 0x, 0b and 0o mean?

They are prefixes that say the base, so 10 cannot be read the wrong way. 0x10 is hex (16), 0b10 is binary (2), and 0o10 is octal (8). With From set to Auto, this tool reads them, and also #FF (a CSS color) and 0FFh (assembly). A number with no prefix is decimal, unless it has the letters A to F.

What is base 36 used for?

Base 36 uses all ten digits and all 26 letters, so it writes big numbers in few characters. Sites use it for short IDs in links: the number 2,176,782,335 is just zzzzzz. Set From or To to Base 36. The tool reads letters in any case.

What is two's complement?

It is how computers store negative whole numbers. In a fixed number of bits, the first bit counts as minus: in 8 bits it is -128, so 11111111 is -1 and 10000000 is -128. Set Signed to 8, 16, 32 or 64 bits to read and write numbers this way.

Can it convert fractions?

Yes. FF.8 in hex is 255.5, and 0.75 is 0.11 in binary. Some fractions never end in another base: 0.1 in binary is 0.000110011... with 0011 repeating forever. The tool cuts the answer after 16 digits (8 to 64 in Options) and names the digits that repeat.

Are big numbers exact?

Yes. The tool uses BigInt, so there is no limit and no rounding. Many converters round past 2^53: they turn FFFFFFFFFFFFFFFF into 18446744073709552000. Here it is 18446744073709551615, to the last digit.

Are my numbers sent anywhere?

No. The numbers are converted in your browser, with JavaScript BigInt. Nothing is uploaded, and there are no ads or cookie walls. You can check this in your browser's network tab while you use it.