W3docs

Tools

Number Base Converter

Convert a number between any two bases from 2 (binary) to 36. Common bases — binary, octal, decimal, hexadecimal — are labeled for convenience.

About the number base converter

This tool converts a whole number from one base to another — any base from 2 (binary) through 36, not just the common ones. Type a number, choose the base it’s currently written in, choose the base you want it in, and the result updates on every keystroke; there’s no Convert button because the underlying math is fast enough not to need one. Common bases are labeled in the dropdowns (2 = binary, 8 = octal, 10 = decimal, 16 = hex) so you don’t have to remember which number means what. Everything runs in the browser — nothing you type is sent to a server.

Conversion itself is two native JavaScript calls: parseInt(input, fromBase) reads the string in the source base, then .toString(toBase) renders it in the target base, uppercased to match the legacy tool’s output (ff becomes FF). The catch: parseInt alone is too forgiving — parseInt('12', 2) silently returns 1 instead of erroring, because it stops at the first digit that doesn’t belong in base 2 rather than rejecting the whole string. This tool validates every character against the source base’s alphabet first and shows an inline error for anything parseInt would otherwise mangle. A leading - or + is accepted for signed numbers; anything else is rejected outright.

You’ll reach for this when reading a hex dump, decoding a Unix file-permission octal like 755 to see which bits are set, converting a binary literal from a datasheet into decimal, or generating short base-36 identifiers (digits 0-9 plus a-z) for URLs. One limit worth knowing: input is parsed as a regular JavaScript number, exact only up to Number.MAX_SAFE_INTEGER (2^53 − 1, about 9 quadrillion). Convert something larger — a 64-bit hash or a UUID segment, for instance — and the result silently rounds to the nearest representable value instead of throwing.

Examples

Decimal to hex and back, in plain JSjs
(255).toString(16).toUpperCase(); // "FF"
parseInt("FF", 16);               // 255

This is exactly what the tool does for its default input (255, decimal → hex). toString(16) returns lowercase digits, hence the .toUpperCase().

Octal file permission to binary (chmod 755)text
Input:      755
From base:  8 (octal)
To base:    2 (binary)
Result:     111101101

111 101 101 grouped in 3s is rwx r-x r-x — the exact bits chmod 755 sets, owner/group/other.

Large hex values lose precision past 2^53js
// This tool: parseInt + Number.prototype.toString
parseInt("ffffffffffffffff", 16).toString(10);
// "18446744073709552000" — off; exact value ends "...551615"

// Exact for 64-bit values: BigInt
BigInt("0xffffffffffffffff").toString(10);
// "18446744073709551615"

Number.MAX_SAFE_INTEGER is 2^53 − 1. This tool — like any parseInt + toString(base) code — silently rounds past it. Reach for BigInt when the exact value matters: hashes, UUIDs, 64-bit flags.

Frequently asked questions

Does this tool use two's complement for negative numbers?

No. Negative numbers are represented with a leading minus sign, not two's complement. Converting -1 from decimal to binary returns -1, not 11111111 — it maps the mathematical value rather than simulating fixed-width signed-integer storage.

Why does it say my number is invalid for the base I picked?

Every character in the input must be a valid digit for the selected base — 8 and 9 aren't valid octal (base 8) digits, and g isn't a valid hex (base 16) digit. The tool checks this strictly before converting, rather than silently truncating the input the way JavaScript's own parseInt does.

Can I convert decimals like 3.14, or only whole numbers?

Only whole numbers (integers). A decimal point isn't a valid digit in any base's alphabet, so input like 3.14 is rejected with an inline error instead of being silently truncated to 3, which is what raw parseInt would do.

What's the largest number this tool converts accurately?

Up to Number.MAX_SAFE_INTEGER — 9,007,199,254,740,991, or 2^53 − 1 — because input is parsed as a standard JavaScript number. Beyond that, results round to the nearest value a double-precision float can represent; for exact 64-bit values, convert with BigInt in your own code instead.

Why does the base selector stop at 36?

Base 36 uses all 10 digits plus all 26 letters of the alphabet (0-9 then a-z) — there are no more single-character symbols left to represent a digit. This also matches the documented limit of JavaScript's own Number.prototype.toString(radix).

How it works

  1. Enter your number — integers only. A leading - is accepted for negatives.
  2. Pick the source base.If the input contains a digit that isn't valid for that base, an inline error appears.
  3. Pick the destination base — anywhere from 2 to 36.
  4. Done. The result updates as you type; click Swap to flip from/to with the current result as the new input.