Number Base Converter - Binary, Octal, Decimal, Hex and Any Base from 2 to 36

Type a whole number in any base from 2 to 36 and see it in binary, octal, decimal, hexadecimal and one more base of your choice.

About this tool

The maths uses BigInt, so a 200-bit number converts exactly instead of being rounded. Negative numbers are shown with a sign, and a table shows how the same value is stored in 8, 16, 32 and 64 bits in two's complement. Fractions are out of scope: this converter works with whole numbers only.

How it works

How place value works. In base b every digit is worth the digit times b raised to its position, counting from 0 on the right. The decimal number 255 is 2 x 10^2 + 5 x 10^1 + 5 x 10^0. The binary number 1010 is 1 x 2^3 + 0 x 2^2 + 1 x 2^1 + 0 x 2^0 = 8 + 2 = 10. Digits above 9 are written with letters, a for 10 up to z for 35, so hexadecimal needs a to f and base 36 uses the whole alphabet.

Converting by repeated division. To write a number in base b, divide it by b, keep the remainder, then divide the quotient again, until the quotient is 0. The remainders read from last to first are the digits. For 156 in binary: 156 / 2 = 78 r 0, 78 / 2 = 39 r 0, 39 / 2 = 19 r 1, 19 / 2 = 9 r 1, 9 / 2 = 4 r 1, 4 / 2 = 2 r 0, 2 / 2 = 1 r 0, 1 / 2 = 0 r 1, so the answer is 10011100. The tool lists these steps for any number below 2^32, and the positional expansion for the number you typed.

Why BigInt. An ordinary JavaScript number is a 64-bit floating point value that can represent every whole number exactly only up to 2^53 - 1, about 9 quadrillion. Past that, digits are silently lost. BigInt has no size limit, and BigInt.prototype.toString accepts any radix from 2 to 36, which is why this tool can show 2^200 as 1606938044258990275541962092341162602522202993782792835301376 and as a 1 followed by 200 zeros in binary. Input is limited to 4,000 digits to keep the page quick.

Negative numbers and two's complement. The main results show the sign and then the magnitude, so -255 is -11111111 in binary and -ff in hex. Computers store negative whole numbers differently: in n bits, a negative x is stored as 2^n + x, and the signed range is -2^(n-1) to 2^(n-1) - 1. So -5 in 8 bits is 256 - 5 = 251, which is 11111011 or FB. The table shows the pattern for 8, 16, 32 and 64 bits, says when a value does not fit, and for a pattern that fits only as unsigned, what it would mean if read as signed.

What you can type. Spaces and underscores between digits are ignored, and so are commas in decimal when they separate groups of three digits, so 1_000_000 and 1,000,000 both work. A comma anywhere else, as in 1,5, is refused rather than read as 15. A leading + or - is accepted. The prefixes 0x (hexadecimal), 0b (binary) and 0o (octal) switch the base for you, unless the letter is a real digit in the base you chose: in hexadecimal, 0b1 is the three digits 0, b and 1. An invalid digit is highlighted with the digits the base allows, and a decimal point is reported because fractions are not converted.

Worked examples

255 in every base

255 is 11111111 in binary (eight 1s, 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1), 377 in octal (3 x 64 + 7 x 8 + 7), FF in hexadecimal (15 x 16 + 15) and 73 in base 36 (7 x 36 + 3). The first three are the usual way to write the largest value of one byte.

-5 in 8 bits

Take 2^8 = 256 and add -5: 251. In binary that is 11111011, and in hexadecimal FB. Read the same eight bits as an unsigned number and you get 251; read them as signed and you get -5. The signed 8-bit range is -128 to 127, so -129 does not fit in 8 bits but does in 16.

A number too big for a calculator

2^200 is 1606938044258990275541962092341162602522202993782792835301376 in decimal, which is 61 digits. Hexadecimal is a 1 followed by fifty 0s (0x1 and 50 zeros, because 200 / 4 = 50), and binary is a 1 followed by 200 zeros. Paste the decimal back in and the converter returns exactly the same figures.

Reading a prefixed number

0xFF in the number box is read as hexadecimal even if the base is set to decimal, and gives 255. 0b1010_1010 is 170: the underscore is only a visual separator. In base 16, 0b1010 is not binary: it is the hexadecimal number B1010, which is 725,008 in decimal.

Powers of two, exact

PowerDecimalHexadecimalWhere you meet it
2^010x1One value: a single bit set
2^120x2Two values: one bit
2^240x4Four values: two bits
2^380x8Eight values: three bits, one octal digit
2^4160x1016 values: four bits, one hexadecimal digit
2^5320x2032 values
2^6640x4064 values
2^71280x80128 values
2^82560x100256 values: one byte, 0 to 255
2^95120x200512 values
2^1010240x4001,024: one kibibyte (KiB) in bytes
2^1120480x8002,048 values
2^1240960x10004,096: a common memory page size in bytes
2^1381920x20008,192 values
2^14163840x400016,384 values
2^15327680x800032,768: one more than the largest signed 16-bit number
2^16655360x1000065,536 values: two bytes, 0 to 65,535
2^2010485760x100000One mebibyte (MiB) in bytes
2^24167772160x100000016,777,216 values: three bytes, the number of RGB colours
2^3010737418240x40000000One gibibyte (GiB) in bytes
2^3121474836480x80000000One more than the largest signed 32-bit number
2^3242949672960x100000000Four bytes: 4,294,967,296 values, the size of the IPv4 address space
2^4010995116277760x10000000000One tebibyte (TiB) in bytes
2^5390071992547409920x20000000000000One more than JavaScript's largest safe integer, 2^53 - 1
2^6392233720368547758080x8000000000000000One more than the largest signed 64-bit number
2^64184467440737095516160x10000000000000000Eight bytes: the number of values in a 64-bit unsigned integer
2^1283402823669209384634633746074317682114560x100000000000000000000000000000000The size of the IPv6 address space and of a UUID
2^20016069380442589902755419620923411626025222029937827928353013760x100000000000000000000000000000000000000000000000000Too big for a JavaScript number; shown exactly because this tool uses BigInt

Frequently asked questions

How do I convert binary to decimal?

Write the place values 1, 2, 4, 8, 16 and so on from the right, and add the ones that sit under a 1. For 10011100 that is 128 + 16 + 8 + 4 = 156. The tool shows this expansion digit by digit for any number you type.

How do I convert decimal to hexadecimal?

Divide by 16 repeatedly and keep the remainders, writing remainders 10 to 15 as A to F. 255 / 16 = 15 remainder 15, then 15 / 16 = 0 remainder 15, so the digits from last to first are F and F: 255 is FF. Set the division steps to base 16 to see it laid out.

What is the biggest number this converter accepts?

Up to 4,000 digits in the number you type. BigInt itself has no fixed limit, but the cap keeps the page fast on a phone. A 4,000-digit decimal number is roughly 13,000 bits, far beyond the 64-bit integers most programs use.

What is two's complement?

It is the way computers store signed whole numbers in a fixed number of bits. A negative x in n bits is stored as 2^n + x, so adding it to the matching positive number overflows to exactly zero. It gives one range, -2^(n-1) to 2^(n-1) - 1, and addition works the same for positive and negative values.

Why does the converter show a minus sign instead of two's complement for negatives?

A base has no built-in sign, so the readable form is a minus sign followed by the magnitude, the same as BigInt.prototype.toString does. The width-specific two's complement patterns are in the table below the results, for 8, 16, 32 and 64 bits.

Can it convert fractions such as 0.1 to binary?

No, this tool is limited to whole numbers and reports a decimal point as an error. Fractions need a different method, and many such as 0.1 repeat forever in binary, which is why 0.1 + 0.2 is not exactly 0.3 in floating point.

Why do hexadecimal numbers use letters?

Base 16 needs sixteen digit symbols and there are only ten numerals, so the letters a to f stand for 10 to 15. Case does not matter: ff and FF are the same number. Hexadecimal is popular because one hex digit is exactly four bits, so a byte is two digits.

What is base 36 used for?

Base 36 uses 0 to 9 and a to z, the largest base that needs only digits and letters of one case, so it writes a number in the fewest such characters. It is handy for short identifiers that encode a number. JavaScript's toString(36) and parseInt(text, 36) use the same digits, and so does this tool.

Updated Oct 15, 2026