Number Base Converter
Convert an integer between binary (base 2), octal (base 8), decimal (base 10) and hexadecimal (base 16).
Last updated: June 20, 2026 · Reviewed by TG we-Calculate Editorial TeamFrom base
Same integer shown in all four bases below.
How do you convert a number between bases?
To convert a number to base 10, multiply each digit by the base raised to its position (counting from zero on the right) and add the results. To go from decimal to another base, repeatedly divide by the target base and read the remainders bottom-up. This tool does both automatically.
Formula
How this is calculated
You supply two inputs: the value (a string of digits) and the "from base" (the radix that string is written in — 2, 8, 10 or 16). The converter first checks that every character is a legal digit for that base: base 2 allows only 0–1, base 8 allows 0–7, base 10 allows 0–9, and base 16 adds A–F (case-insensitive). If any character is out of range, the input is rejected rather than silently truncated.
The value is then decoded into a single decimal integer using positional notation: each digit is multiplied by the base raised to the power of its position, counting from zero on the right, and the products are summed. So binary 1010 becomes 1×2³ + 0×2² + 1×2¹ + 0×2⁰ = 10. That one integer is the canonical value; it is re-encoded into all four bases for display, with hexadecimal shown in uppercase by convention.
The tool handles only non-negative whole numbers — no signs, fractions or separators. It also assumes exact integer arithmetic, so values above 2⁵³−1 (9,007,199,254,740,991) are rejected to avoid floating-point rounding errors.
Examples
| Input | Result |
|---|---|
| Binary 1010 → decimal | 10 |
| Decimal 255 → hexadecimal | FF |
| Hexadecimal 1F → octal | 37 |
Frequently asked questions
Hex digits A–F can be written in either case, but uppercase is the most common convention for memory addresses, colour codes and documentation, so the result uses uppercase.
This converter handles non-negative whole numbers (integers). Fractions and signs are not supported, since binary/octal/hex fractions follow separate rules.
Up to 9,007,199,254,740,991 (2⁵³−1), the largest integer JavaScript can represent exactly. Larger values are rejected to avoid rounding errors.
Also known as
Sources & references
TG we-Calculate Editorial Team. (2026). Number Base Converter [Online calculator]. TG we-Calculate. https://we-calculate.com/calculator/number-base-converter
TG we-Calculate Editorial Team. "Number Base Converter." TG we-Calculate. 2026. https://we-calculate.com/calculator/number-base-converter.
TG we-Calculate Editorial Team, "Number Base Converter," TG we-Calculate, 2026. [Online]. Available: https://we-calculate.com/calculator/number-base-converter
@misc{wecalculate_number_base_converter, title = {Number Base Converter}, author = {{TG we-Calculate Editorial Team}}, howpublished = {\url{https://we-calculate.com/calculator/number-base-converter}}, year = {2026}, note = {TG we-Calculate} }
Did this calculator help you?
