How to use
- Enter the number you want to convert.
- Select the base it is written in, from 2 to 36 or Base62.
- Read the result in binary, octal, decimal, hex, Base36 and Base62 at the same time.
- For any other base, choose it as the custom target base.
Numbers, not bytes
This tool converts the value of a number. The decimal number 255 is 11111111 in binary, 377 in octal, ff in hex and 73 in Base36.
Byte encodings such as Base16 and Base2 do something else: they encode text or files. The text 255 is three characters, stored as the bytes 32 35 35 in hex, or 00110010 00110101 00110101 in binary. Use this page for the hex of a number, and the byte encoders for the hex of characters or a file.
How positional bases work
In every base, each digit is worth the base raised to the power of its position, counted from the right starting at zero. Hex ff is 15 × 16 + 15 = 255, and binary 11111111 is 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = 255. Bases above 10 continue the digits with letters, so a means 10 and z means 35 in Base36. Base62 adds the other letter case as well, so upper and lower case letters have different values there.
One hex digit stands for exactly 4 bits and one octal digit for 3 bits. That is why programmers use hex and octal as a short way to write binary: 1111 1111 becomes ff group by group.
Large and negative numbers
The converter uses arbitrary-precision integers (JavaScript BigInt), so long numbers stay exact. Many calculators and plain JavaScript numbers lose precision above 9007199254740991 (2 to the power of 53, minus 1). For example, parseInt('ffffffffffffffff', 16) returns 18446744073709552000, while the correct value, the largest unsigned 64-bit integer, is 18446744073709551615.
A negative number is converted with its minus sign, so -255 is -ff in hex. This is not the two's complement form used for fixed-width integers in memory. To get that, add 2 to the power of the width first: for 8 bits, -1 + 256 = 255, which is ff. Only whole numbers are supported, not fractions. Everything runs in your browser.
Base conversion in code
// JavaScript
parseInt('ff', 16); // 255
(255).toString(2); // '11111111'
BigInt('0xffffffffffffffff').toString(10); // '18446744073709551615'
# Python
int('ff', 16) # 255
bin(255), oct(255), hex(255) # ('0b11111111', '0o377', '0xff')
Frequently asked questions
How do I convert binary to decimal?
Enter the binary number, select base 2 and read the decimal result. By hand, add the place values of every 1 digit: 1010 in binary is 8 + 2 = 10.
How do I convert decimal to hex?
Enter the number with base 10 selected and read the hex result. By hand, divide by 16 repeatedly and write the remainders in reverse order: 255 divided by 16 is 15 remainder 15, which gives ff.
Is there a limit on the size of the number?
There is no fixed limit. The tool uses BigInt arithmetic, so a number with hundreds of digits converts exactly. Very long numbers simply take a little longer.
Why is the hex of 255 here different from the Base16 encoder?
Can I convert numbers with a fractional part?
No. The converter works with integers only. Fractions such as 0.1 often have no exact representation in another base, so they are outside its scope.