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.
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
- 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).
- Type or paste the value into the Number field. The page opens with 255 as an example.
- Read the Binary, Octal, Decimal and Hexadecimal rows. There is no Convert button; the results change as you type or switch the base.
- To copy a result, select the text in its row and copy it as usual.
Input rules and options explained
- Prefixes — a prefix is removed only when it matches the selected base:
0xfor hexadecimal,0ofor octal and0bfor binary, in either case (0B101works). With Decimal selected,0xFFis rejected rather than guessed. - Separators — spaces and underscores anywhere in the input are ignored, so
1111 0000,0b1111_0000andDEAD_BEEFare all accepted. Commas and full stops are not. - Letter case — hex digits can be typed in upper or lower case; the Hexadecimal result is always shown in upper case.
- Negative numbers — a leading minus sign is kept in every base (−10 becomes
-1010and-A). A plus sign is not accepted, and-0is shown as 0. - Leading zeros — allowed and dropped from the results: decimal
00017is 17. - Size — the digits are read with JavaScript’s
BigInt, so there is no upper limit and no rounding.
Common problems and fixes
Invalid input clears the results and shows a message such as Invalid number for base 2. Allowed digits: 0 1.
| Symptom | Cause | Fix |
|---|---|---|
“Invalid number for base 10” for 0xFF | The prefix does not match the selected base. | Select Hexadecimal (base 16), or delete the prefix. |
Error for 1,000 or 3.75 | Commas 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 elsewhere | Other 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 -A | The 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-five | In 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) | Binary | Octal | Decimal | Hex | Where you see it |
|---|---|---|---|---|---|
755 (8) | 111101101 | 755 | 493 | 1ED | chmod 755: rwx r-x r-x |
1E (16) | 11110 | 36 | 30 | 1E | Red channel of #1E90FF |
C0A80101 (16) | 11000000101010000000000100000001 | 30052000401 | 3232235777 | C0A80101 | 192.168.1.1 stored as a 32-bit integer |
246 (10) | 11110110 | 366 | 246 | F6 | −10 as an 8-bit two’s complement byte |
18446744073709551615 (10) | 64 ones | 1777777777777777777777 | 18446744073709551615 | FFFFFFFFFFFFFFFF | Largest 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.