Number Base Converter - Binary, Octal, Decimal & Hex Online
Convert numbers between binary, octal, decimal, and hexadecimal instantly. Interactive bit visualization and bitwise operation calculator.
Frequently Asked Questions
What is a Number Base Converter?
A Number Base Converter is a tool that translates numbers between different numeral systems (bases). The most common bases in computing are binary (base 2, using 0 and 1), octal (base 8, using 0-7), decimal (base 10, using 0-9), and hexadecimal (base 16, using 0-9 and A-F). Each base represents the same numerical value differently. For example, the decimal number 255 is 11111111 in binary, 377 in octal, and FF in hexadecimal.
How do I use this Number Base Converter?
Enter a number in any of the four input fields (Binary, Octal, Decimal, or Hexadecimal) and all other fields instantly update with the converted values. Use the bit visualization below to see and interact with individual bits. Click any bit to toggle it on or off. Adjust the bit width (8/16/32/64) and signed/unsigned mode as needed. Use the copy button next to each field to copy the result.
Is my data safe? Does anything get sent to a server?
All number conversion and bit manipulation is performed 100% in your browser using JavaScript. No data is transmitted to any server. The tool uses the browser's built-in BigInt for precise calculations. Your numbers never leave your device, making this tool safe for converting sensitive values like memory addresses or security-related numbers.
What is two's complement and how does signed mode work?
Two's complement is the standard method computers use to represent negative integers in binary. In signed mode, the most significant bit (leftmost) acts as the sign bit: 0 for positive, 1 for negative. For example, in 8-bit signed mode, 11111111 represents -1 (not 255), and 10000000 represents -128. The range of an 8-bit signed integer is -128 to 127, while unsigned is 0 to 255.
What are bitwise operations and when are they useful?
Bitwise operations manipulate individual bits of numbers directly. AND (&) is used for masking specific bits, OR (|) for setting bits, XOR (^) for toggling bits, NOT (~) for flipping all bits, and shift operators (<<, >>) for multiplying/dividing by powers of 2. They are essential in systems programming, network protocols, graphics programming, cryptography, and performance-critical code.
Why does hexadecimal use letters A-F?
Hexadecimal (base 16) needs 16 unique digits. Since our decimal system only provides digits 0-9 (ten symbols), hexadecimal uses letters A through F to represent values 10 through 15. This makes hex a compact way to represent binary data: each hex digit maps to exactly 4 binary bits (a nibble), so FF = 11111111 = 255.
How do I choose the right bit width?
Choose the bit width based on the data type you are working with: 8-bit for bytes and ASCII characters (range 0-255), 16-bit for short integers and Unicode BMP characters (range 0-65535), 32-bit for standard integers, IPv4 addresses, and color values (range 0-4.29 billion), and 64-bit for large integers, memory addresses, and timestamps. When in doubt, use 32-bit as it covers most common use cases.
Code Examples
// Number base conversion in JavaScript
// Convert between bases
function convertBase(number, fromBase, toBase) {
const decimal = BigInt(parseInt(number, fromBase));
return decimal.toString(toBase).toUpperCase();
}
console.log(convertBase('FF', 16, 2)); // "11111111"
console.log(convertBase('11111111', 2, 16)); // "FF"
console.log(convertBase('255', 10, 8)); // "377"
// Bitwise operations
const a = 0b11001010, b = 0b10110001;
console.log(`AND: ${(a & b).toString(2).padStart(8, '0')}`);
console.log(`OR: ${(a | b).toString(2).padStart(8, '0')}`);
console.log(`XOR: ${(a ^ b).toString(2).padStart(8, '0')}`);
console.log(`NOT: ${((~a) & 0xFF).toString(2).padStart(8, '0')}`);
// Two's complement
function toTwosComplement(value, bits) {
if (value >= 0) return value;
return (1 << bits) + value;
}
console.log(toTwosComplement(-1, 8).toString(2)); // "11111111"