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

Example 1: Decimal 255 β†’ Binary / Octal / Hex
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).
Example 2: Binary 1010 β†’ Decimal / Octal / Hex
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.
Example 3: Hexadecimal FF β†’ Decimal / Binary / Octal
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).
Example 4: Octal 777 β†’ Decimal / Binary / Hex
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

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

Embed this tool on your site

Free to embed, no sign-up. Paste this code where you want the number base converter to appear: