Binary / Decimal / Hex Converter
Enter a non-negative integer and its base to instantly see it converted to binary, octal, decimal, and hexadecimal.
โโโโExamples
| Decimal | Binary | Octal | Hex |
|---|---|---|---|
| 10 | 1010 | 12 | A |
| 255 | 11111111 | 377 | FF |
| 4096 | 1000000000000 | 10000 | 1000 |
| 64 | 1000000 | 100 | 40 |
| 101 | 1100101 | 145 | 65 |
| 65535 | 1111111111111111 | 177777 | FFFF |
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
- Choose the base your input value is written in (or leave it on Auto-detect).
- Type the value.
- 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: