Number Base
Ready to try Number Base?
Access the free online tool now - no registration required
Number Base - Complete Guide
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.
How It Works
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.
Technical Details
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.
Common Use Cases
- Programming: Convert between hex, binary, and decimal for debugging.
- Digital Electronics: Work with binary and hex representations.
- Color Codes: Convert hex colors to/from decimal RGB values.
- Encoding: Understand Base64, Base32 encoding numerically.
Code Examples
Number Base Conversion
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.
Tips & Best Practices
- Hex: each digit = 4 bits
- Octal: each digit = 3 bits
- Prefix conventions: 0x (hex), 0b (binary), 0o (octal)
- Validate input for source base
- Handle uppercase/lowercase for hex
Common Mistakes to Avoid
- Wrong base for input parsing
- Forgetting case sensitivity
- Not handling leading zeros
- Precision loss with large numbers
When to Use This Tool
Use number base converter when programming, debugging, working with colors, file permissions, or any situation requiring numeral system conversion.
Frequently Asked Questions
Why is hex used in programming?
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.
What is octal used for?
Unix file permissions (chmod 755 = rwxr-xr-x). Each octal digit = 3 bits = one rwx group. Legacy: early computers used 6-bit or 12-bit words divisible by 3.
Can I convert fractions?
Yes, but may not be exact. 0.1 decimal is infinite in binary (0.0001100110011...). Same as 1/3 is infinite in decimal (0.333...). Round appropriately.
What about negative numbers?
Treat sign separately, or use two's complement for binary. Two's complement: -1 = 11111111 in 8-bit. Conversion tools may differ in handling.
Get Started
Ready to try Number Base? Use the tool now - it's free, fast, and works right in your browser.
Last updated: June 27, 2026
Start using Number Base
Free, fast, and privacy-focused - try it now
Share this article
Related Tools
Crontab
Crontab - Professional online developer tool. Fast, accurate, and free. Perfect for developers, designers, and technical professionals. Works offline and respects your privacy.
Luhn
Luhn - Professional online developer tool. Fast, accurate, and free. Perfect for developers, designers, and technical professionals. Works offline and respects your privacy.
Responsive Tester
Responsive Tester - Professional online developer tool. Fast, accurate, and free. Perfect for developers, designers, and technical professionals. Works offline and respects your privacy.
Timestamp
Timestamp - Professional online developer tool. Fast, accurate, and free. Perfect for developers, designers, and technical professionals. Works offline and respects your privacy.