What the Number Base Converter does
The Number Base Converter reads a whole number in the base you select, Binary (2), Octal (8), Decimal (10) or Hexadecimal (16), and shows its binary, octal, decimal and uppercase hexadecimal forms side by side. Each form has a Copy button that writes it to the clipboard.
Conversion uses JavaScript's BigInt type rather than ordinary floating-point numbers. An ordinary Number can only represent integers exactly up to 2^53 minus 1, which is 9,007,199,254,740,991; BigInt has no such ceiling, so a 64-bit value such as 18446744073709551616 or a 256-bit hash converts digit for digit.
The default example is 255 in decimal, which shows 11111111, 377 and FF. Typical uses are reading Unix file permissions in octal, checking a color code or memory address in hex, or working through a binary arithmetic exercise.
How to use it
Select the input base
Choose Binary, Octal, Decimal or Hexadecimal from the Input base list so the tool knows how to read your digits.
Type the number
Enter only digits valid for that base, with an optional leading minus sign. Underscores are allowed as visual separators and are ignored, so 1_000_000 works.
Copy the form you need
Read the four results and press Copy next to any of them. Hex output is uppercase; add your own 0x or 0b prefix if your language needs one.
Which characters each base accepts
Validation is strict and happens before conversion. Binary accepts 0 and 1; octal 0 to 7; decimal 0 to 9; hexadecimal 0 to 9 and A to F in either case. A leading minus sign is allowed, leading zeros are allowed, and underscores anywhere in the digits are stripped. Anything else, including a plus sign, a decimal point, spaces between digits or a 0x prefix, produces the message that the value contains a digit not valid for the selected base.
That strictness is deliberate. A lenient parser such as parseInt stops silently at the first bad character, so parseInt('1F', 10) returns 1 and hides the mistake. Here you see an error instead of a wrong answer.
How negative numbers are shown
Negative input is converted as a sign and a magnitude: -255 appears as -11111111 in binary and -FF in hex. This matches how BigInt's toString(radix) works. It is not the two's complement bit pattern a CPU would store, where -1 in eight bits is 11111111. If you need two's complement, add 2^n to the negative value first, where n is the word size, then convert the positive result.
Why exactness matters for large values
Many online converters use the Number type, which rounds integers above 9,007,199,254,740,991. The lowest digits then change, which is a silent failure for 64-bit identifiers, nanosecond timestamps, cryptographic values and database keys. This tool keeps every digit because BigInt arithmetic is arbitrary precision; the only practical limit is how long a string your browser can hold in an input field.
- 255 (decimal) = 11111111 (binary) = 377 (octal) = FF (hex)
- 9007199254740993 stays 9007199254740993, where a floating-point conversion would end in 992
- 18446744073709551616, which is 2^64, = 10000000000000000 (hex, seventeen digits)
- File mode 755 (octal) = 493 (decimal) = 111101101 (binary)
Limits to know before you rely on it
- Integers only. Fractions, decimal points and exponent forms such as 1e10 are rejected; convert the whole part separately if that is what you need.
- Only bases 2, 8, 10 and 16 are available; there is no base 32, base 36 or custom radix, and no bit-width option.
- Negative numbers are output with a minus sign (sign and magnitude), not as two's complement bit patterns.
- Prefixes such as 0x, 0b and 0o are not accepted in the input and are not added to the output.
- Copy uses the browser clipboard API, which some browsers block inside embedded frames or until you grant permission.
Questions people ask about the Number Base Converter
Can I paste a hex value with a 0x prefix?
No. Choose Hexadecimal as the input base and enter only the digits, so 0x1F becomes 1F. The letter x is not a valid hex digit, so the prefixed form is rejected with an error message.
Why do I get an error for 9 in octal or 2 in binary?
Each base has a fixed digit set: binary 0 to 1, octal 0 to 7, decimal 0 to 9, hex 0 to F. A digit outside that set means either the digits or the selected base is wrong, and the tool refuses to guess which.
How large a number can it convert?
There is no fixed ceiling because BigInt is arbitrary precision. Values far beyond 64 bits convert exactly; the practical limit is the length of text your browser will hold in an input field.
Does it convert fractions like 0.1 to binary?
No. The converter handles whole numbers only. A decimal point is treated as an invalid character and produces an error rather than a truncated result.
Is lowercase hex accepted, and why is the output uppercase?
Input accepts a to f and A to F interchangeably. Output is always uppercase (FF rather than ff) for consistency; most languages and CSS accept either case, so lowercase it after copying if you prefer.
How do I get the two's complement of a negative number?
Add 2 to the power of your word size to the value first. For -1 in 8 bits, enter 255 (256 minus 1) in decimal and read 11111111 in binary; for -1 in 32 bits, enter 4294967295 and read FFFFFFFF in hex.
Sources and further reading
- MDN Web Docs, BigInt: arbitrary-precision integers and why Number loses precision above 2^53
- MDN Web Docs, BigInt.prototype.toString(): the radix argument used to produce the binary, octal, decimal and hex output
- MDN Web Docs, parseInt(): radix parsing and how it stops at the first invalid character, the behaviour this tool deliberately avoids
- MDN Web Docs, Number.MAX_SAFE_INTEGER: the 9,007,199,254,740,991 limit of exact integers in floating point