Number Base Converter

Convert a number between binary, octal, decimal and hexadecimal at once, live as you type. Results are exact for integers of any size, and a 0x, 0b or 0o prefix is accepted when it matches the selected base.

Binary—
Octal—
Decimal—
Hexadecimal—

What does a number base converter do?

A number base converter rewrites the same integer in a different positional system. Decimal (base 10) uses ten digits; binary (base 2) uses two; octal (base 8) uses eight; hexadecimal (base 16) uses 0–9 plus A–F for the values ten to fifteen. The value does not change, only the way it is written: 255, 11111111, 377 and FF are one number. This tool shows all four forms at once and updates them on every keystroke.

Programmers meet these bases constantly: hex in colour codes, hashes, memory addresses and byte dumps; octal in Unix file permissions; binary in bit masks, flags and network masks. JavaScript, Python, Rust and many other languages accept the literal prefixes 0x, 0o and 0b (see the numeric literals section of the ECMAScript specification).

How to use the converter

  1. Choose the base of the number you already have in the drop-down next to Number: Binary (base 2), Octal (base 8), Decimal (base 10) or Hexadecimal (base 16).
  2. Type or paste the value into the Number field. The page opens with 255 as an example.
  3. Read the Binary, Octal, Decimal and Hexadecimal rows. There is no Convert button; the results change as you type or switch the base.
  4. To copy a result, select the text in its row and copy it as usual.

Input rules and options explained

Common problems and fixes

Invalid input clears the results and shows a message such as Invalid number for base 2. Allowed digits: 0 1.

SymptomCauseFix
“Invalid number for base 10” for 0xFFThe prefix does not match the selected base.Select Hexadecimal (base 16), or delete the prefix.
Error for 1,000 or 3.75Commas and decimal points are not digits; only whole numbers are converted.Remove thousands separators. Convert the integer part only, or use a floating-point tool.
A large ID ends in different digits elsewhereOther code parsed it as a JavaScript Number, which is exact only up to 253.Trust the BigInt result here; in your own code, keep large IDs as strings or BigInt.
Expected FFFFFFF6 but got -AThe tool shows a signed value, not a fixed-width two’s complement pattern.Add 2n for an n-bit width (see the example below).
0755 converts as seven hundred and fifty-fiveIn Decimal mode a leading zero is just a zero. C and older JavaScript treat 0755 as octal.Select Octal (base 8) or type 0o755 with Octal selected.

Worked examples

Each row was entered into this converter with the base shown.

Input (base)BinaryOctalDecimalHexWhere you see it
755 (8)1111011017554931EDchmod 755: rwx r-x r-x
1E (16)1111036301ERed channel of #1E90FF
C0A80101 (16)11000000101010000000000100000001300520004013232235777C0A80101192.168.1.1 stored as a 32-bit integer
246 (10)11110110366246F6−10 as an 8-bit two’s complement byte
18446744073709551615 (10)64 ones177777777777777777777718446744073709551615FFFFFFFFFFFFFFFFLargest unsigned 64-bit value

Hex is convenient because one hex digit is exactly four bits, so a byte is always two hex digits. Octal digits are three bits each, which is why every digit of a permission such as 755 lines up with one read-write-execute triple.

Converting by hand

To decimal: multiply each digit by the base raised to its position, counting from zero on the right. Hex 2F is 2 × 16 + 15 × 1 = 47.

From decimal: divide by the target base repeatedly and read the remainders from last to first. 47 → 23 r1 → 11 r1 → 5 r1 → 2 r1 → 1 r0 → 0 r1 gives 101111.

Two’s complement: to store −10 in 8 bits, add 28: 256 − 10 = 246, which the converter shows as F6. For 32 bits, add 4294967296 instead and you get FFFFFFF6.

Frequently asked questions

Is there a limit on how big the number can be?

No practical limit. The converter uses BigInt, so values such as 9007199254740993 stay exact. A plain JavaScript Number('9007199254740993') returns 9007199254740992, because ordinary numbers lose precision above 253.

Why does it not detect the base automatically?

Many strings are valid in several bases: 10 could be two, eight, ten or sixteen. Choosing the base explicitly avoids silent mistakes, and a prefix is only accepted when it agrees with your choice.

Can I convert fractions or floating-point values?

No, only whole numbers. Many decimal fractions have no exact binary form, which is why 0.1 + 0.2 evaluates to 0.30000000000000004 in JavaScript.

What is the difference between 0o755 and 0755?

In C, and in non-strict JavaScript, 0755 is octal. The leading-zero form is a syntax error in JavaScript strict mode and in Python 3, which use the explicit 0o prefix instead. That prefix is the one this tool recognises.

How do I convert a hex colour to RGB?

Convert each pair separately with Hexadecimal selected: in #1E90FF, 1E is 30, 90 is 144 and FF is 255. The Color Converter does all three at once and adds HSL.

Is the number I type sent anywhere?

No. The conversion is a few lines of JavaScript running in your browser, and the input is not sent to a server.

Guides

Related tools