Number Base Converter
Convert a number between any base from 2 to 36 and see it rendered in binary (base 2), octal (base 8), decimal (base 10), and hexadecimal (base 16) at once. Enter a value in its source base — with an optional 0x, 0b, or 0o prefix and either case — and every representation updates instantly. The radix conversion is plain positional notation: base-N to decimal via Horner's method (value = Σ digit × base^position), decimal to base-N via JavaScript's Number.prototype.toString(radix), which is specified to emit lowercase digits for radix 2 through 36 (ECMA-262). A separate Base64 mini-tool encodes and decodes text per RFC 4648 (standard alphabet, UTF-8 via TextEncoder/TextDecoder, so it behaves identically in the browser and on the server). Values are limited to the JavaScript safe-integer range (2^53 − 1) so that no conversion ever returns a silently-rounded result. Primary references: ECMA-262 Number.prototype.toString(radix), RFC 4648, and MDN's Number.toString documentation.
View the TypeScript implementation on GitHub: packages/calc/src/base-converter.ts · view tests
What this means
Every integer is the same number; a base is just the alphabet you write it in. Base 10 has ten digits, base 2 has two, base 16 has sixteen (0–9 then a–f). Converting between them never changes the value — only its spelling. That is why a memory address, an IPv4 address, a color, and a permission bitmask are all happiest in whichever base makes their structure visible: hex for byte boundaries, binary for individual bits, octal for the three-bit Unix permission groups.
The conversion itself is two small algorithms. Reading a number out of its source base is Horner’s method — fold the digits left to right, multiplying the running total by the base and adding the next digit. Writing it into a target base is repeated division — peel off the remainder mod the base, divide, repeat, then read the remainders backwards. In JavaScript the second step is exactly what Number.prototype.toString(radix) does, and ECMA-262 guarantees it works for any radix from 2 to 36 with lowercase digits.
When I built this, the detail I cared most about was the safe-integer ceiling. A JavaScript number is an IEEE-754 double, which can only hold every integer exactly up to 253 − 1; above that, consecutive integers start sharing the same float and a base conversion would quietly return the wrong value. In my experience the worst bugs in tooling like this are the silent ones — a converter that returns a plausible-but- wrong hex string is more dangerous than one that refuses. So this tool throws on overflow, on illegal digits, and on malformed Base64 rather than guessing.
Worked example
Take the decimal value 255. To write it in binary, divide by 2 repeatedly and read the remainders backwards: 255÷2 = 127 r1, 127÷2 = 63 r1, … all the way down, giving eight 1-bits: 11111111. To write it in hex, divide by 16: 255÷16 = 15 r15, and 15 is the hex digit f, so 255 = 0xff. In octal, divide by 8: 255 = 3×64 + 7×8 + 7 = 377. Reverse the process with Horner’s method to confirm: 0xff back to decimal is f×16 + f = 15×16 + 15 = 240 + 15 = 255.
Now Base64. Encoding the three ASCII bytes of the word Man— M=77, a=97, n=110 — gives 24 bits: 01001101 01100001 01101110. Regrouped into four 6-bit chunks that is 010011 010110 000101 101110 = 19, 22, 5, 46, which map to T W F u in the RFC 4648 alphabet. Because the input was an exact multiple of 3 bytes, no = padding is needed: Man → TWFu. I’ve found that remembering the 3-bytes-to-4- characters ratio is the fastest way to sanity-check a Base64 string by eye: its length is always a multiple of four, and one or two trailing = signs tell you the original byte count mod 3.
Frequently asked questions
The information and tools on this website are for general educational purposes only and do not constitute financial, investment, legal, or tax advice. Consult a licensed professional for decisions specific to your situation.