Number Base Converter — Convert Between Any Bases 2-36
Convert numbers between any two bases from binary (base 2) to base 36. Supports hexadecimal, octal, binary, and all custom bases.
The formula
N_b = d_{n-1} × b^{n-1} + d_{n-2} × b^{n-2} + ... + d_0 × b^0
- b
- Base
- d_i
- Digit at Position i
- N_b
- Number in Base b
- n
- Digit Count
How Base Converter Works
N_b = d_{n-1} × b^{n-1} + d_{n-2} × b^{n-2} + ... + d_0 × b^0
A number in any base b is represented as a sequence of digits where each digit position represents a power of the base. Converting between bases involves first interpreting the number in its source base (expanding each digit multiplied by base raised to its positional power) and then expressing that decimal value in the target base by repeatedly dividing by the target base and collecting remainders.
- b
- Base — The number of unique digits used in a positional numeral system. Binary (b=2) uses 0-1, decimal (b=10) uses 0-9, hexadecimal (b=16) uses 0-9 and A-F, and base-36 uses all digits 0-9 and letters A-Z representing values 10-35.
- d_i
- Digit at Position i — Each digit in the number represents a coefficient at a specific positional power of the base. Position i=0 is the rightmost (units) position, i=1 is the next (b^1 position), and so on. The value contributed by digit d at position i is d × b^i.
- N_b
- Number in Base b — The complete number expressed in the positional numeral system with base b. The total decimal value is the sum of all digit contributions: Σ (d_i × b^i) for all positions i from 0 to n-1, where n is the digit count.
- n
- Digit Count — The number of digits in the converted result. Also called the length of the representation. A larger base generally produces fewer digits to represent the same value. For example, 255 decimal = FF in hex (2 digits) = 11111111 in binary (8 digits).
How to Use
- Enter the number you want to convert in the "Input Number" field. Use uppercase letters A-Z for digits above 9 (e.g., "FF" for 255 in hex, "101010" for 42 in binary).
- Set "From Base" to the base of your input number (minimum 2, maximum 36). For example, set 16 for hexadecimal input, 2 for binary, 10 for decimal, 8 for octal.
- Set "To Base" to the target base you want to convert to. The calculator converts the input to decimal first, then to the target base using repeated division.
- Review the converted result (highlighted), the intermediate decimal value for verification, the input validation status confirming all digits are valid for the source base, and the digit count.
- For base conversions above 10, remember that letters A (10) through Z (35) represent digits beyond 9. For example, "1A" in base 16 = 1×16¹ + 10×16⁰ = 26 in decimal.
Quick Reference
| Binary (base 2) | 0, 1 |
| Octal (base 8) | 0–7 |
| Decimal (base 10) | 0–9 |
| Hexadecimal (base 16) | 0–9, A–F |
| Base 36 | 0–9, A–Z |
| 255 decimal | FF in hex, 11111111 in binary |
| 42 decimal | 2A in hex, 101010 in binary, 52 in octal |
| Powers of 2 shortcut | 4 binary bits = 1 hex digit (nibble) |
Common Uses
- •Computer science and programming — converting between binary, octal, hexadecimal, and decimal for low-level programming, memory addressing, color codes, and debugging.
- •Digital electronics and embedded systems — working with register values, memory maps, and hardware configuration where hexadecimal and binary are standard notations.
- •Networking — converting IP addresses between dotted-decimal and binary notation, subnet masks, and MAC addresses between decimal and hexadecimal representations.
- •Cryptography and data encoding — understanding base-64 encoding concepts and working with hash values displayed in hexadecimal format, commonly used in blockchain and digital signatures.
- •Educational settings — learning how positional numeral systems work across different cultures and building intuition about number representation in computer science curricula.
Understanding the Result
Number base conversion is a fundamental concept in mathematics and computer science with roots in ancient civilizations. The Babylonians used a sexagesimal (base-60) system around 2000 BCE, which still influences our measurement of time (60 seconds per minute) and angles (360 degrees in a circle). The Mayans independently developed a vigesimal (base-20) system, while the Hindu-Arabic decimal system we use today originated in India around 500 CE and reached Europe through Arabic mathematicians in the 10th century. Every positional numeral system represents numbers using a fixed set of digits and positional weights that are powers of the base. In base 10 (decimal), which we use in everyday life, the digits 0-9 are multiplied by powers of 10: the number 342 means 3×10² + 4×10¹ + 2×10⁰ = 300 + 40 + 2. The same principle applies to any base. Binary (base 2) uses only two digits (0 and 1) and powers of 2, making it the natural language of digital circuits where each bit represents an on/off state — the German mathematician Gottfried Wilhelm Leibniz developed the modern binary system in 1679. Hexadecimal (base 16) is widely used in computing because one hex digit corresponds exactly to four binary digits (a nibble), making it much more compact for representing binary data. Converting a number from its source base to a target base follows a two-step process. First, interpret the source representation by expanding: multiply each digit by the source base raised to its positional power and sum the results to get the decimal value. Second, convert the decimal to the target base: repeatedly divide the decimal number by the target base, collecting the remainders from right to left, which become the digits of the result. This algorithm, known as the division-remainder method, works for any base between 2 and 36.
Worked Examples
Carlos, a firmware engineer, is debugging a microcontroller that reports a register value of 0x7B in hexadecimal. The datasheet says bits 3-5 control the clock divider. He needs to see the binary representation to extract those bits.
input = 7B · fromBase = 16 · toBase = 2
1111011 (base 2), Decimal = 123
0x7B in binary is 1111011 (or padded to 8 bits: 01111011). Bits 3-5 (counting from bit 0 at right) are positions 3, 4, 5: 111. The clock divider value is 7. Carlos can now configure the clock register correctly. Understanding binary-to-hex relationships is essential for embedded programming — each hex digit maps to exactly 4 binary digits, making hex the preferred notation for register values.
Aisha, a computer science student, is studying for her networking exam. She needs to convert the subnet mask 255.255.255.0 from dotted-decimal to binary notation to understand how many host bits are available.
input = 255 · fromBase = 10 · toBase = 2
11111111 (base 2), Decimal = 255
255 in binary is 11111111, so the full mask in binary is 11111111.11111111.11111111.00000000. The eight zeros at the end mean there are 2^8 = 256 possible addresses (254 usable hosts excluding network and broadcast addresses). Aisha converts each octet individually using the calculator, verifying her understanding of subnetting fundamentals — the number of consecutive 1-bits in the binary mask determines the network prefix length (/24 in CIDR notation).
David, a web developer, is working with URL shorteners and needs to understand base conversion for generating compact IDs. He wants to encode a database ID like 1234567 into base-62 (0-9, a-z, A-Z) or the nearest supported base-36 for a compact URL-safe string.
input = 1234567 · fromBase = 10 · toBase = 36
QGLJ (base 36), Decimal = 1234567
1234567 in base 36 is QGLJ. This is a 4-character ID instead of a 7-character decimal ID — a 43% reduction in length. Base-36 encoding uses all alphanumeric characters (0-9, A-Z), making it URL-safe without case sensitivity issues. For production URL shorteners, base-62 (adding lowercase letters) would compress further, giving even shorter IDs, but base-36 is the maximum this calculator supports since base-62 requires additional character distinctions beyond the 36 alphanumeric symbols.
Frequently Asked Questions
- How do I know if my input digits are valid for the selected source base?
- Each digit must be less than the base. In base 10, valid digits are 0-9. In base 2 (binary), only 0 and 1 are valid. In base 16 (hexadecimal), valid digits are 0-9 and A-F. In base 36, valid digits are 0-9 and A-Z. The calculator checks every digit and returns an empty result if any digit is invalid for the specified source base. For example, entering "2G" with base 16 would be invalid because G (value 16) equals the base and is not allowed for base 16.
- Why does the same number have different digit counts in different bases?
- Digit count is inversely related to the size of the base. A larger base can represent more values per digit, so fewer digits are needed. For example, the number 255 (decimal) requires 8 digits in binary (11111111), 3 digits in octal (377), 2 digits in hex (FF), and 3 digits in decimal (255). This relationship follows from the formula: digit count = floor(log_base(value)) + 1. Understanding this helps explain why hexadecimal is preferred over binary for human readability in computing.
- What happens if I use a base larger than 36?
- This calculator only supports bases 2 through 36. Bases beyond 36 would require additional symbols beyond the 10 decimal digits and 26 letters of the English alphabet. While arbitrary bases are theoretically possible, they are rarely used in practice. Base 36 is the largest base that can be represented using only alphanumeric characters (0-9 and A-Z). For contexts requiring larger bases, specialized notations exist (such as base-64 encoding), but they use additional characters like + and /.
- How do I convert between bases without a calculator?
- To convert from any base to decimal, multiply each digit by the base raised to its positional power (starting from 0 at the rightmost position) and sum the results. To convert from decimal to another base, repeatedly divide by the target base and read the remainders from bottom to top. For powers-of-two bases (binary, octal, hex), there is a shortcut: group binary digits and convert each group directly (4 bits = 1 hex digit, 3 bits = 1 octal digit). For example, binary 11010011 can be grouped as 1101 0011 = D3 in hex.
- What are the most common base conversions in programming?
- The most common conversions are: binary to hex (each group of 4 bits = 1 hex digit), hex to decimal (for color codes like #FF5733 and memory addresses), decimal to binary (for bitmask and flag calculations), and hex to binary (for understanding individual bit patterns). Most programming languages provide built-in functions for these: parseInt(str, radix) and Number.toString(radix) in JavaScript, int(str, base) in Python, and Integer.parseInt(str, radix)/Integer.toString(int, radix) in Java.
- Why did ancient civilizations use different number bases?
- Different bases evolved from practical counting methods. The Babylonians used base-60 (sexagesimal) because 60 has many divisors (1, 2, 3, 4, 5, 6, 10, 12, 15, 20, 30), making division without fractions easier for trade and astronomy. This system survives today in our 60-second minutes and 360-degree circles. The Mayans used base-20 (vigesimal), likely counting on fingers and toes. Base-12 (duodecimal) appears in dozens and grosses from medieval European trade. The decimal system (base-10) prevailed primarily because humans have 10 fingers, making it the most intuitive counting system across cultures.
- What is the relationship between binary, octal, and hexadecimal?
- Binary, octal, and hexadecimal are all powers-of-two bases. Octal (base 8 = 2³) maps 3 binary digits to 1 octal digit, while hexadecimal (base 16 = 2⁴) maps 4 binary digits to 1 hex digit. This makes conversion between them trivial: group binary digits and convert each group directly. Octal was historically important in early computing (e.g., the PDP-11 used octal notation), but hexadecimal has largely replaced octal in modern computing because 8-bit bytes map cleanly to exactly 2 hex digits, whereas 8 bits do not divide evenly into octal groups.
Pro Tips
- →When converting between binary and hexadecimal, use the nibble shortcut: each hex digit is exactly 4 binary digits. Group binary digits from right to left in groups of 4. For example, binary 11010011 groups as 1101 0011 = D3 in hex. This is far faster than converting to decimal first.
- →For powers-of-two bases (2, 4, 8, 16, 32), conversions are exact and lossless. For bases that are not powers of two, there may be fractional representation differences, though this calculator handles integers only, so all conversions are exact.
- →The digit count follows the formula: digits needed = floor(log_base(value)) + 1. Use this to predict how large your result will be before converting. A decimal number with d digits will have roughly d × log₁₀(base) digits in the target base.
- →Invalid digit detection is automatic: if you try to parse "39" as octal (base 8), the calculator rejects it because digit 9 does not exist in base 8. Similarly, "G" is invalid in hexadecimal despite being a letter. Each base accepts digits from 0 to (base-1).
- →For color code conversions in web development (e.g., #FF5733), each pair of hex digits represents one RGB channel. FF = 255 (red), 57 = 87 (green), 33 = 51 (blue). While this calculator handles the numeric conversion, specialized color picker tools integrate this logic with visual previews.
- →The intermediate decimal value shown in results is your verification checkpoint. If the decimal looks wrong, the parse step had an error — double-check your input digits and source base. If the decimal is correct but the result looks wrong, the conversion step had an issue — verify the target base.
Limitations to Know
- •This calculator handles integer conversions only between bases 2 through 36. Fractional numbers (e.g., 10.5 in base 2) are not supported — fractional base conversion requires a separate algorithm that multiplies the fractional part by the base and collects integer parts.
- •Numbers exceeding JavaScript's safe integer range (Number.MAX_SAFE_INTEGER = 9,007,199,254,740,991) may lose precision during the decimal intermediate step. For arbitrary-precision base conversion of very large integers, use the Big Number calculator with its BigInt support.
- •Bases beyond 36 are not supported as they would require additional symbol sets beyond 0-9 and A-Z. Base-64 encoding (which uses + and /) and other non-standard positional systems like balanced ternary or negative bases are out of scope.
- •Do not use this calculator for IEEE 754 floating-point representation analysis, bitwise operation visualization, or endianness conversion. These are specialized hardware-level concerns handled by dedicated tools.
Cite this calculator
TheCalcUniverse. "Number Base Converter — Convert Between Any Bases 2-36." TheCalcUniverse, 2026, https://thecalcuniverse.com/math/base-converter/. Accessed July 24, 2026.
Embed this calculator on your site
You may also like
-
Binary & Hex
Convert between Decimal, Binary, Hex, and Octal with positional value breakdown. Perform arithmetic and bitwis…
-
Sci Notation
Convert between decimal and scientific notation. Learn how the decimal point jumps left or right with an inter…
-
Arbitrary Precision
Perform exact arbitrary-precision integer arithmetic with BigInt. Add, subtract, multiply, divide, and exponen…
-
Rounding Calculator
Round numbers to the nearest million, thousand, hundred, ten, unit, tenth, hundredth, thousandth, or ten-thous…