Number Base Converter
Convert integers between binary, octal, decimal, and hexadecimal with arbitrary precision.
- Binarybase 2
11011110101011011011111011101111
- Octalbase 8
33653337357
- Decimalbase 10
3735928559
- Hexadecimalbase 16
deadbeef
How it works
Type a number, choose the base it is written in, and its binary, octal, decimal, and hexadecimal forms appear together, each with its own copy button. Changing the input base reinterprets the same digits, so 10 can be read as ten, two, eight, or sixteen without retyping it.
Values are parsed with JavaScript's BigInt rather than ordinary numbers, so there is no 2^53 limit and no silent rounding. A 64-bit mask, a 128-bit identifier, or a 256-bit hash written in hex converts exactly, digit for digit.
Input is forgiving about formatting. The base's own prefix (0b for binary, 0o for octal, 0x for hex) is optional, hex digits can be upper or lower case, and spaces or underscores used to group digits, as in 1111 0000 or 1_000_000, are ignored. A leading minus sign is kept and applied to every result.
Anything that is not a digit of the chosen base, such as a 2 in binary or a decimal point, is reported by name instead of being skipped, so a typo never produces a plausible but wrong value.
Frequently asked questions
- How do I convert binary to decimal?
- Multiply each bit by the power of two for its position, counting from zero on the right, and add the results. 1011 is 8 + 0 + 2 + 1, which is 11. Select Binary as the input base and the tool does this for numbers of any length.
- Why does one hex digit equal four binary digits?
- Because 16 is 2 to the fourth power, so each hex digit covers exactly four bits. That is why ff is 11111111 and why hex is the usual shorthand for bytes, masks, and memory addresses. Octal works the same way with three bits per digit.
- Can it convert negative numbers to two's complement?
- No. A negative input is shown with a minus sign in every base, such as -ff, because two's complement depends on a fixed bit width that the input does not specify. Add 2 to the power of the width to the value if you need that representation.
- Does it support fractions or floating-point numbers?
- No, only integers. A decimal point is rejected as an invalid digit, because most fractions that are exact in one base repeat forever in another, and rounding them silently would be misleading.
- Is there a maximum number size?
- Only your browser's memory. Conversion uses BigInt arithmetic, so numbers with hundreds of digits convert exactly, far beyond the 9,007,199,254,740,991 limit of ordinary JavaScript numbers.