Skip to content
RightYantra
Text & developer

Number Base Converter

Convert a number from any base between 2 and 36 to any other, and see it in binary, octal, decimal, hexadecimal and base 36 at the same time. Numbers of any length convert exactly, fractional parts are expanded honestly, and negative numbers get their two's-complement bit patterns.

How to use it· 4 steps
  1. Type the number. Spaces, underscores and 0x / 0b / 0o prefixes are fine, and a minus sign or a fractional point work too.
  2. Choose the base it is written in and the base you want. The swap button reverses them and carries the result across.
  3. Read the result, or the same value in every common base below it, and copy whichever you need.
  4. Open Show the working for the hand method, or the two's complement panel for the bits an 8, 16, 32 or 64-bit register would hold.
Number Base ConverterRuns on your device

Step by step

How to use the number base converter

  1. 1Type the number. Spaces, underscores and 0x / 0b / 0o prefixes are fine, and a minus sign or a fractional point work too.
  2. 2Choose the base it is written in and the base you want. The swap button reverses them and carries the result across.
  3. 3Read the result, or the same value in every common base below it, and copy whichever you need.
  4. 4Open Show the working for the hand method, or the two's complement panel for the bits an 8, 16, 32 or 64-bit register would hold.

How positional bases work

In any positional system, a digit's worth depends on where it sits. In decimal, 345 means 3 hundreds, 4 tens and 5 ones — each position is worth ten times the one to its right. Base b works the same way with powers of b instead of powers of ten, so 345 in base 8 means 3 × 64 + 4 × 8 + 5 = 229 in decimal.

A base needs as many distinct digits as its size. Binary uses 0 and 1; octal 0–7; decimal 0–9. Beyond ten, letters stand in: A is 10, B is 11, up to F for 15 in hexadecimal and Z for 35 in base 36, which is why 36 is where this converter stops — it is the largest base you can write with the ten digits and the 26 letters of the Latin alphabet. Letters are read case-insensitively, so ff and FF are the same number.

A digit that does not exist in the chosen base is an error, not something to quietly skip. Typing 9 into an octal number or G into a hex one gets a message naming the digit, its position and the range the base allows.

Why big numbers stay exact here

JavaScript's ordinary numbers are 64-bit floating point, which can only represent every integer up to 2^53 − 1, or 9,007,199,254,740,991. Past that, odd numbers start to disappear: converting 9,007,199,254,740,993 to hex with the usual parseInt and toString returns 20000000000000, which is the hex for the number one below. Many online converters have exactly this bug and show no sign of it.

This converter uses BigInt, the arbitrary-precision integer type built into modern browsers, so a 128-bit hash, a 64-bit database ID or a 200-digit number converts digit for digit. You can check it by converting a long number to some base and back again: it returns unchanged.

Fractions: exact, repeating or cut off

Fractions are where base conversion becomes subtle. A fraction ends in a given base only if its denominator, in lowest terms, has no prime factors the base lacks. One tenth has a denominator of 10 = 2 × 5; binary has only the factor 2, so 0.1 in decimal is 0.000110011001100… in binary, repeating forever. One third ends in base 3 (0.1) and base 12 (0.4) but never in base 10.

So every fractional result is labelled. Exact means the expansion terminated. Repeats forever shows the repeating block in brackets — 0.0(0011) for one tenth in binary — found by noticing when the same remainder comes round a second time. Cut off means the digits went on past your chosen precision without repeating within it. Precision is adjustable from 1 to 256 fractional digits and defaults to 32.

The repeating binary form of 0.1 is the reason 0.1 + 0.2 prints as 0.30000000000000004 in most programming languages: neither number can be stored exactly in binary floating point, and the tiny rounding errors add up where you can see them.

Negative numbers and two's complement

The main result writes negative numbers the way people do, with a minus sign: −255 in hex is −FF. Computers do not store a minus sign. A signed integer in a fixed number of bits uses two's complement, where a negative value −x is stored as 2^n − x. In 8 bits, −1 is 256 − 1 = 255, or 11111111.

The two's complement panel shows the 8, 16, 32 and 64-bit patterns for any whole number, with the hex alongside. It also says when a value only fits as unsigned — 200 fits in 8 bits as 11001000, but a program reading those bits as a signed byte gets −56 — and when it does not fit at all, which is what an overflow is. An 8-bit signed integer holds −128 to 127; 16 bits hold −32,768 to 32,767; 32 bits about ±2.1 billion.

Where each base turns up

Binary is the language of hardware, bit flags and network masks. Octal survives in Unix file permissions — chmod 755 is three octal digits, each one three permission bits. Hexadecimal is everywhere a programmer looks at bytes: memory addresses, colour codes like #1E90FF, MAC addresses, Unicode code points and error codes. Base 36 packs a large number into few characters using only letters and digits, which is why it shows up in short IDs and URL shorteners.

Two things that look like bases are not handled here. Base 32 in this tool is the positional base with digits 0–9 and A–V; the RFC 4648 Base32 encoding used for TOTP secrets uses a different alphabet (A–Z and 2–7) and encodes bytes, not a number. Likewise Base64 is a byte encoding rather than a number base — for that, use the Base64 encoder.

Answers

Frequently asked questions

What is the largest number this can convert?

There is no practical limit. Integers use the browser's BigInt type, so a number with hundreds of digits converts exactly. The step-by-step working is only listed for numbers up to 40 digits, to keep it readable.

Why does 0.1 never end in binary?

A fraction terminates in a base only when its denominator's prime factors all divide the base. One tenth has a factor of 5, which binary does not have, so it repeats forever as 0.0(0011). The tool shows the repeating block in brackets.

What is two's complement?

The way computers store signed whole numbers in a fixed number of bits: a negative value −x is stored as 2^n − x. In 8 bits, −1 is 11111111 and −128 is 10000000. The two's complement panel shows the pattern at 8, 16, 32 and 64 bits.

Why does the converter reject 0x in a decimal number?

The 0x prefix means hexadecimal, so 0x1F typed with the input base set to 10 almost always means the base setting is wrong. Change the input base to 16, or delete the prefix.

Is base 32 here the same as Base32 encoding?

No. This is the positional number base with digits 0–9 and A–V. RFC 4648 Base32 encodes bytes with the alphabet A–Z and 2–7, so the two give different results.

Are lower-case letters accepted?

Yes — ff, Ff and FF are the same number. Output uses capitals by default; turn on lower-case letters if your code style prefers them.