Number Base Converter (Binary, Octal, Decimal, Hex)
Instantly convert any integer between binary (base 2), octal (base 8), decimal (base 10), and hexadecimal (base 16) β all four results update live as you type.
Enter a number above to see its representation in all four bases.
Quick answer
To convert between number bases, enter a value in any base and the tool automatically converts it to all other bases. Binary uses digits 0β1, octal uses 0β7, decimal uses 0β9, and hexadecimal uses 0β9 and AβF. For example, decimal 255 equals binary 11111111, octal 377, and hexadecimal FF. Conversion works by first expressing the number as a sum of powers of its source base, then re-expressing that value in the target base.
Formula & method
Nββ = dβββ Γ b^n + β¦ + dβ Γ bΒΉ + dβ Γ bβ°
- Nββ β Decimal (base 10) equivalent of the number
- dβββ β Digit at position n (leftmost = most significant)
- b β Source base (2 for binary, 8 for octal, 16 for hex)
- n β Zero-indexed position of the digit from the right
Any positional number in base b converts to decimal by multiplying each digit by b raised to its position index.
Examples
- Input
- 255 (decimal, base 10)
- Result
- Binary: 11111111 | Octal: 377 | Hex: FF
- Why
- 255 = 128+64+32+16+8+4+2+1, which sets all 8 bits to 1 giving binary 11111111. Grouped in threes from the right: 011|111|111 = 377 in octal. Grouped in fours: 1111|1111 = FF in hex (F = 15).
- Input
- 1010 (binary, base 2)
- Result
- Decimal: 10 | Octal: 12 | Hex: A
- Why
- 1Γ2Β³ + 0Γ2Β² + 1Γ2ΒΉ + 0Γ2β° = 8+0+2+0 = 10 decimal. 10 divided by 8 gives 1 remainder 2, so octal 12. In hex, 10 is a single digit represented as A.
- Input
- FF (hexadecimal, base 16)
- Result
- Decimal: 255 | Binary: 11111111 | Octal: 377
- Why
- FΓ16ΒΉ + FΓ16β° = 15Γ16 + 15Γ1 = 240+15 = 255 decimal. 255 in binary is 11111111 (eight 1-bits). In octal that is 377 (3Γ64 + 7Γ8 + 7 = 255).
- Input
- 777 (octal, base 8)
- Result
- Decimal: 511 | Binary: 111111111 | Hex: 1FF
- Why
- 7Γ8Β² + 7Γ8ΒΉ + 7Γ8β° = 448+56+7 = 511 decimal. 511 in binary is 111111111 (nine 1-bits). In hex: 511 = 1Γ256 + 255 = 1Γ16Β² + 15Γ16 + 15, giving 1FF.
Frequently asked questions
Why do programmers use hexadecimal instead of binary?
Hexadecimal is far more compact than binary β every 4 binary digits collapse into one hex digit. A 32-bit value takes 32 characters in binary but only 8 in hex, making memory addresses, color codes, and bytecodes much easier to read and type.
What is the difference between base 2, base 8, base 10, and base 16?
Base 2 (binary) uses only 0 and 1 and maps directly to transistor on/off states. Base 8 (octal) uses digits 0β7 and groups binary bits in threes. Base 10 (decimal) is the everyday counting system using 0β9. Base 16 (hexadecimal) uses 0β9 plus AβF and groups binary bits in fours.
How do I convert a hex letter like A, B, C to a number?
The hex digits A through F represent the decimal values 10 through 15 respectively. A=10, B=11, C=12, D=13, E=14, F=15. When converting, substitute these values before performing the positional multiplication.
Can this converter handle large numbers?
The converter uses JavaScript's built-in parseInt and toString methods, which support safe integers up to 2^53β1 (about 9 quadrillion in decimal). For most programming tasks β addresses, color codes, flags β this is more than sufficient.
Why does octal start with 0 in C and Python?
In C (and many C-descended languages including Python 3 with the 0o prefix), a leading zero signals octal notation to the compiler/interpreter. This convention dates to early Unix where octal file permissions (e.g. chmod 755) were common.
What are common real-world uses of number base conversion?
Hexadecimal is used for HTML/CSS color codes (#FF5733), memory addresses, and machine opcodes. Binary appears in bitmasking, flags, and network subnet masks. Octal was historically used for Unix file permissions (chmod 755 = rwxr-xr-x). Understanding all four bases is essential for low-level programming and computer science.
Sources & references
- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt
- https://www.encyclopediaofmath.org/index.php/Positional_notation
- https://en.wikipedia.org/wiki/Hexadecimal
External references open in a new tab. We are independent and not affiliated with these organizations.
- β Free to use
- β No sign-up required
- β Runs entirely in your browser β nothing is uploaded.
- β Formula and method shown above
Provided βas isβ for general information only β results may be inaccurate, so verify before you rely on them. No warranty; use at your own risk.
Built and reviewed by HIFreeTools against the formula shown above and any authoritative references cited on this page. See our methodology and editorial standards.
Related tools
- Scientific CalculatorScience & Engineering
- Prime Number CheckerCalculators
- Factorial CalculatorCalculators
- Logarithm CalculatorCalculators
Embed this tool on your site
Free to embed, no sign-up. Paste this code where you want the number base converter to appear: