How to convert a number to another base
- Type or paste your numbers into Input, one per line or several on a line.
- Pick the base they’re written in under From and the base you want under To. For any base other than 2, 8, 10 or 16, choose Other and type the base, from 2 to 36.
- Copy the result, which has one line for each input line. Values that aren’t valid in the chosen base are marked so you can fix them. Click Swap to convert the result back.
How number bases work
In any base, each digit is worth the base times as much as the digit to its right. Decimal places are worth 1, 10, 100 and 1000. Binary places are worth 1, 2, 4 and 8, and hex places are worth 1, 16, 256 and 4096. The digits run from 0 up to one less than the base, which is why binary only has 0 and 1 and hex borrows the letters A to F for 10 to 15.
| Base | Name | Digits | Prefix | Where you see it |
|---|---|---|---|---|
| 2 | Binary | 0 and 1 | 0b | Bits, flags and bit masks |
| 8 | Octal | 0 to 7 | 0o | Unix file permissions |
| 10 | Decimal | 0 to 9 | none | Everyday numbers |
| 16 | Hexadecimal | 0 to 9, A to F | 0x | Memory addresses, colour codes, byte dumps |
| 36 | Base 36 | 0 to 9, A to Z | none | Short IDs, such as the post IDs in Reddit links |
Why hex and octal line up with binary
16 is 2 to the 4th power, so each hex digit stands for exactly four bits. 8 is 2 cubed, so each octal digit stands for three. That’s why programmers use hex as shorthand for binary: FF is 1111 1111 and 0x1F4 is 1 1111 0100, one group of bits per hex digit. Decimal doesn’t line up with bits at all, so converting to or from decimal always takes real arithmetic.
Tick Group binary digits in 4s to see this in the output. Binary results are padded with zeros on the left to a multiple of four bits, so 500 shows as 0001 1111 0100, which reads straight across as 1F4.