Binary to Arbitrary Base Converter
Convert binary numbers to any base from 2 to 64. Supports arbitrarily large inputs with BigInt precision. Instant, client-side conversion.
About
Radix conversion errors propagate silently. A misinterpreted binary payload in protocol design or firmware can cause data corruption that surfaces days later. This tool converts binary strings of arbitrary length to any target base b where 2 ≤ b ≤ 64, using native BigInt arithmetic to avoid the IEEE 754 53-bit mantissa limit that breaks standard parseInt past 253. The digit alphabet follows the Base64 convention: 0 - 9, then A - Z, then a - z, then + and /.
Limitation: this tool assumes unsigned (non-negative) integers only. Two’s complement or floating-point binary representations require separate decoding before input. Leading zeros in the binary input are stripped before conversion. For bases above 36, the output is case-sensitive: A (value 10) and a (value 36) are distinct digits.
Formulas
The binary input string B of length n is first converted to a decimal integer D using positional notation:
The decimal value D is then converted to the target base b by repeated Euclidean division. At each step, the remainder r gives the next digit (least significant first):
Digits are collected until D = 0, then reversed. Each remainder r is mapped to a character from the alphabet: 0 - 9 → digits, 10 - 35 → A - Z, 36 - 61 → a - z, 62 → +, 63 → /.
Where Bi = the i-th bit (from left), n = total bit count, b = target base (2 - 64), D = intermediate decimal (BigInt), r = remainder digit value.
Reference Data
| Base | Name | Digit Set | Common Use |
|---|---|---|---|
| 2 | Binary | 0-1 | CPU instructions, bitfields |
| 3 | Ternary | 0-2 | Balanced ternary logic, Setun computer |
| 4 | Quaternary | 0-3 | DNA encoding (A, T, G, C mapping) |
| 5 | Quinary | 0-4 | Bi-quinary coded decimal systems |
| 7 | Septenary | 0-6 | Week-day encoding |
| 8 | Octal | 0-7 | Unix file permissions (chmod 755) |
| 10 | Decimal | 0-9 | Human-readable numbers |
| 12 | Duodecimal | 0-9, A - B | Time (12 hours), imperial units |
| 16 | Hexadecimal | 0-9, A - F | Memory addresses, CSS colors, MAC addresses |
| 20 | Vigesimal | 0-9, A - J | Mayan numeral system |
| 32 | Base32 | 0-9, A - V | Crockford encoding, TOTP secrets (RFC 4648) |
| 36 | Base36 | 0-9, A - Z | URL shorteners, compact IDs |
| 58 | Base58 | Alphanumeric minus 0OIl | Bitcoin addresses, IPFS CIDs |
| 60 | Sexagesimal | 0-9, A - Z, a - x | Babylonian math, time (60 sec/min) |
| 62 | Base62 | 0-9, A - Z, a - z | Short URLs (bit.ly), session tokens |
| 64 | Base64 | 0-9, A - Z, a - z, +, / | Email attachments (MIME), data URIs, JWT |