Binary / Decimal / Hex Converter

Enter a non-negative integer and its base to instantly see it converted to binary, octal, decimal, and hexadecimal.

Processed locally in your browser. Your data is not uploaded to our servers.

Binaryโ€”
Octalโ€”
Decimalโ€”
Hexadecimalโ€”

Examples

DecimalBinaryOctalHex
10101012A
25511111111377FF
40961000000000000100001000
64100000010040
101110010114565
655351111111111111111177777FFFF

Formula & Methodology

Each base represents numbers using a different number of digit symbols (its "radix"):

binary = base 2 (0โ€“1) ยท octal = base 8 (0โ€“7) ยท decimal = base 10 (0โ€“9) ยท hex = base 16 (0โ€“9, Aโ€“F)

What the converter accepts

  • Positional notation. Each digit is multiplied by the base raised to its position, so binary 1010 = 1ร—8 + 0ร—4 + 1ร—2 + 0ร—1 = 10. In hexadecimal the letters Aโ€“F stand for 10โ€“15, and letter case does not matter when you type them.
  • Prefixes. You may type the prefix that belongs to the selected base: 0x for hexadecimal, 0b for binary or 0o for octal, in any letter case. A prefix from a different base is not removed, so in hexadecimal โ€œ0b101โ€ is read as the hex digits 0, B, 1, 0, 1.
  • Auto-detect is a guess. A prefix decides the base; otherwise a value made only of 0s and 1s is read as binary, other digit-only values as decimal, and anything with letters as hexadecimal. So โ€œ101โ€ is read as binary (5). Choose Decimal in the Input base list to convert decimal 101.
  • Non-negative integers only. Minus signs, decimal points, thousands separators and spaces inside the value are rejected as invalid digits, and fractions and floating-point numbers are not supported.
  • Large numbers. Values are handled as arbitrary-size integers (BigInt), so 2โถโด = 18446744073709551616 converts exactly to hexadecimal 10000000000000000. Results are shown without prefixes, and hexadecimal in uppercase.

How to Use

  1. Choose the base your input value is written in (or leave it on Auto-detect).
  2. Type the value.
  3. All four representations update instantly below.

Frequently Asked Questions

Does this support negative numbers?

No โ€” this tool currently supports non-negative integers only. Negative number and fractional support may be added in a future update.

How large a number can I convert?

The tool uses JavaScriptโ€™s BigInt internally, so it can handle arbitrarily large integers without losing precision โ€” unlike using regular floating-point numbers.

What does "Auto-detect" do?

It guesses the base from the format of what you typed โ€” a 0x prefix is treated as hex, 0b as binary, 0o as octal, and plain digits are treated as binary if they only contain 0s and 1s, otherwise decimal.

Why does 101 convert as binary?

With Auto-detect on, a value made only of 0s and 1s is read as binary. Select Decimal in the Input base list to treat 101 as one hundred and one (binary 1100101, hexadecimal 65).

Why do I get an โ€œinvalid digitsโ€ error?

The value contains a character that does not belong to the selected base, such as 2 in binary, 8 in octal or G in hexadecimal. Commas, spaces, minus signs and decimal points are rejected too.

Is hexadecimal input case-sensitive?

No. ff, FF and 0xFf are the same value. Hexadecimal results are shown in uppercase.

Last updated: