Convert numbers between binary, octal, decimal, and hexadecimal
Convert numbers between binary, octal, decimal, and hexadecimal formats instantly with our free online number base converter. This tool helps programmers, students, and engineers transform numbers between different number systems with automatic conversion to all bases. Simply enter a number in any base and get conversions to all other bases in real-time.
Decimal Value: 0
Input Base: Decimal (base 10)
Number base converter transforms numbers between different numeral systems: binary (base 2), octal (base 8), decimal (base 10), hexadecimal (base 16), and custom bases up to 36. Essential for programming, digital electronics, and computer science education.
Parse input as number in source base, convert to intermediate decimal, then convert to target base. Each digit is multiplied by base^position. Output digits map 0-9 for values 0-9, A-Z for values 10-35.
Standard bases: binary (0-1), octal (0-7), decimal (0-9), hex (0-9, A-F). Custom bases up to 36 using 0-9 and A-Z. For larger bases, need custom digit symbols. Negative numbers and fractions require special handling.
Convert between hex, binary, and decimal for debugging.
Work with binary and hex representations.
Convert hex colors to/from decimal RGB values.
Understand Base64, Base32 encoding numerically.
function convertBase(number, fromBase, toBase) {
// Parse input as source base
const decimal = parseInt(number, fromBase);
if (isNaN(decimal)) {
throw new Error('Invalid number for source base');
}
// Convert to target base
return decimal.toString(toBase).toUpperCase();
}
// Common conversions
convertBase('255', 10, 16); // "FF"
convertBase('FF', 16, 2); // "11111111"
convertBase('11111111', 2, 10); // "255"
convertBase('777', 8, 10); // "511"
// RGB hex to decimal
function hexToRGB(hex) {
const r = parseInt(hex.slice(0, 2), 16);
const g = parseInt(hex.slice(2, 4), 16);
const b = parseInt(hex.slice(4, 6), 16);
return { r, g, b };
}
hexToRGB('FF8000'); // { r: 255, g: 128, b: 0 }Use parseInt(str, base) and number.toString(base) for conversion. Handle uppercase for hex.
Use number base converter when programming, debugging, working with colors, file permissions, or any situation requiring numeral system conversion.
Hex is compact: each hex digit = 4 bits. A byte is 2 hex digits (00-FF). Easier to read than binary (11111111 = FF) while preserving bit boundaries. Colors: #FF0000 = red.