Number base converter

Type into any field: binary, octal, decimal, and hex stay in sync. Arbitrarily large integers welcome.

How to convert between bases

  1. Type a number into any of the four fields: decimal, hexadecimal, binary, or octal.
  2. Watch the other three fields update on every keystroke. There is no convert button; whichever field you are typing in is the source and the rest follow.
  3. Prefixes like 0x, 0b, and 0o are stripped automatically, and spaces or underscores used as digit separators are ignored, so you can paste values straight out of code.
  4. Check the bit-length line at the bottom, which tells you how many binary bits the value occupies.

A worked example

The page loads with 255 in the decimal field, showing ff in hex, 11111111 in binary, 377 in octal, and "8 bits" below, the largest value one byte can hold. Now go the other way: paste a CSS color channel like 0x1A into the hex field, the prefix is stripped, and decimal shows 26. For something bigger, type 18446744073709551616 (2 to the 64th) into decimal: hex reads 10000000000000000, the bit line reads 65 bits, and a note appears confirming the value is beyond JavaScript's float precision and was handled exactly. Type an invalid digit, like 8 in the octal field, and you get a clear "Not a valid base-8 number" instead of silent garbage.

Why BigInt matters here

Most base converters, including plenty of online ones, run on JavaScript's ordinary numbers, which are 64-bit floats that can only represent integers exactly up to 9,007,199,254,740,991. Past that, conversions silently round, and a rounded hash or ID is worse than no conversion at all. This tool parses every input digit by digit into a BigInt, an arbitrary-precision integer, and re-serializes it into each base, so a 100-digit number converts as exactly as a 2-digit one. The digit-by-digit parser exists because BigInt has no built-in radix parsing; it multiplies the running value by the base and adds each digit, the same algorithm you would use on paper. The bit-length line falls out of this for free, being simply the length of the binary form.

Honest limitations

Integers only: there is no fractional conversion, so you cannot ask what 0.5 is in binary, and no negative numbers either, since the fields validate raw digits. There is also no two's-complement view, which matters if you are debugging signed values; the binary shown is the pure unsigned representation, so -1 as a 32-bit int (ffffffff) will read here as 4294967295, which is correct arithmetic but not what a C programmer squinting at a register wants. The four bases are fixed, with no base-36 or arbitrary radix option. Within its lane, unsigned integers of any size across the four bases programmers actually use, it is exact, instant, and runs entirely in your browser.

Frequently asked questions

Why does hexadecimal exist?

One hex digit is exactly four binary bits, so hex is compressed binary a human can read: 0xFF is 11111111. That is why memory addresses, color codes, and hashes are written in hex.

How large a number can this handle?

Effectively unlimited: it uses JavaScript BigInt rather than floating point, so numbers past the usual 9,007,199,254,740,991 (2^53 - 1) safe-integer limit convert exactly.

Are prefixes like 0x and 0b accepted?

Yes, 0x, 0b, and 0o prefixes are stripped automatically, and spaces or underscores used as digit separators are ignored.