How to convert a number to another base
- Choose the base the number is written in under From, for example decimal.
- Type or paste the number and choose the base you want under To.
- Press Convert or Enter. The result appears with a one-line calculation you can copy. Swap exchanges the two bases and keeps what you typed, so paste the result into the box if you want to convert it back.
The converter works with whole numbers of any length, in every base from 2 to 36. Binary, octal, decimal and hexadecimal have their own names in the list; the others appear as base-3, base-5 and so on. The arithmetic is done with arbitrary-precision integers, so a 20-digit ID or a 64-bit mask comes out exactly, digit for digit.
What you can type
- Digits of the chosen base. Bases above 10 use letters for the extra digits: A is 10, F is 15 and Z is 35. Upper and lower case are the same, so
ffandFFare both 255. - A prefix, for its own base only.
0bis accepted in binary,0oin octal and0xin hexadecimal, in either case. Typing0x1Fwith decimal selected is an error that tells you to choose hexadecimal instead. - Underscores between digits, as in JavaScript, Python and Rust:
1111_0000orff_ff. An underscore at the start or end, or two in a row, is rejected. - A minus sign at the very start. Spaces around the number are ignored.
Fractions, exponents such as 1e3, a plus sign and spaces inside the number are not accepted. Instead of guessing, the converter names the first character it cannot read and its position, for example: Invalid character "2" at position 3: not a base-2 digit (base-2 digits are 0-1).
Worked examples
- 255 decimal to binary: 11111111. To hexadecimal: FF.
- 755 octal to decimal: 7 × 64 + 5 × 8 + 5 × 1 = 448 + 40 + 5 = 493. Each position is worth eight times the one to its right.
- 42 decimal to binary by repeated division by 2, reading the remainders from last to first: 42 → 21 r0 → 10 r1 → 5 r0 → 2 r1 → 1 r0 → 0 r1, giving 101010.
- 0b1111_0000 binary to hexadecimal: F0.
- DEADBEEF hexadecimal to decimal: 3735928559.
- 18446744073709551615 decimal to hexadecimal (the largest unsigned 64-bit value): FFFFFFFFFFFFFFFF.
The same values in common bases
| Base 2 | Base 8 | Base 10 | Base 16 | Base 36 |
|---|---|---|---|---|
| 111 | 7 | 7 | 7 | 7 |
| 1010 | 12 | 10 | A | A |
| 101010 | 52 | 42 | 2A | 16 |
| 1100100 | 144 | 100 | 64 | 2S |
| 11111111 | 377 | 255 | FF | 73 |
| 100000000 | 400 | 256 | 100 | 74 |
| 1111101000 | 1750 | 1000 | 3E8 | RS |
| 111111111111 | 7777 | 4095 | FFF | 35R |
| 1111111111111111 | 177777 | 65535 | FFFF | 1EKF |
One hexadecimal digit stands for exactly four binary digits and one octal digit for exactly three. That is why hexadecimal is used for bytes, memory addresses and colours (FF8800 is 16746496), and octal for Unix file permissions, where 755 is 111101101 in binary: three groups of three bits for owner, group and others.
What the result looks like
Digits above 9 are written in upper case. The result has no prefix, no digit grouping and no leading zeros: 007 in decimal becomes 111 in binary, and 0o644 in octal becomes 110100100. If you need a fixed width, such as 8 or 32 bits, pad the result with zeros on the left yourself.
Negative numbers are not two's complement
A negative number keeps its minus sign: -42 in decimal is -101010 in binary and -2A in hexadecimal, and -1 is simply -1. Computers usually store negative integers in two's complement, where the bit pattern depends on the width. The converter does not choose a width for you, but you can get the pattern by adding 2 to the power of the width first: for an 8-bit value, −42 + 256 = 214, and 214 in binary is 11010110. For a 32-bit value, −1 + 4294967296 = 4294967295, which is FFFFFFFF in hexadecimal.
Common pitfalls
- Letters that are digits. In hexadecimal,
bis the digit 11, so0b101read as hexadecimal is 45313, not 5. Check the selected base before converting a prefixed value. - Precision in other tools. JavaScript numbers are exact only up to 9,007,199,254,740,991, and Excel keeps only 15 significant digits. 9007199254740993 in hexadecimal is 20000000000001 here, while a conversion through a JavaScript number ends in 0 instead of 1.
- Thousands separators. Commas and dots are rejected; remove them or use underscores.
Frequently asked questions
Why does base 36 stop at Z?
Ten digits plus 26 letters give 36 symbols, so 36 is the largest base that can be written with ordinary alphanumeric characters. In base 36, ZZ is 1295.
Can I convert fractions such as 0.1?
No. The converter handles whole numbers only. Many fractions have no exact representation in another base: 0.1 in decimal repeats forever in binary.
Is there a size limit?
There is no fixed limit. Numbers with thousands of digits convert exactly; very long inputs only take longer because the work happens in your browser.
Why is my result shorter than the input?
Leading zeros carry no value and are not written, and higher bases need fewer digits: 65535 is FFFF in hexadecimal.