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. Swap flips the two bases and feeds the result back in, so you can bounce between hex and decimal without retyping.

Conversion uses BigInt, so integers of any length convert exactly — a 64-bit hash or a 20-digit hex value comes out digit-for-digit, with no rounding and no exponent notation. The input may start with a + or - sign and, when it matches the source base, a 0x, 0b or 0o prefix (case-insensitive). Spaces and underscores are ignored as digit separators, so ff ff and 1_000 work. Every other character must be a valid digit for the source base; anything else, including a decimal point, shows an inline error. Output is uppercased (ff becomes FF).

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.

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.

Values past 2^53 stay exacttext
Input:      9007199254740993
From base:  10 (decimal)
To base:    16 (hex)
Result:     20000000000001

A plain JavaScript number would round this to 20000000000000 — the tool uses BigInt, so the last digit survives.

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.

Is there a limit on how large a number I can convert?

No practical one. The tool uses BigInt, so integers of any length convert exactly — only your browser’s memory is the limit. Fractions are not supported.

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.