Number Base Converter | Binary, Hex
Convert numbers between binary, octal, decimal, and hexadecimal bases.
INPUT BASE
CONVERT TO
What Is the Number Base Converter | Binary, Hex?
This number base converter converts any integer between bases 2 and 36. Enter a number in any base and instantly see the equivalent in binary, octal, decimal, hexadecimal, and any custom base simultaneously. A step-by-step division algorithm shows exactly how the conversion is performed, ideal for learning.
- ›All four common bases at once: every conversion shows binary, octal, decimal, and hex results in a single view.
- ›Custom base 2–36: convert to any base using digits 0–9 and A–Z.
- ›Step-by-step division algorithm: the remainder table shows exactly how decimal is converted to the target base.
- ›Large number support: uses JavaScript BigInt for accurate conversion of numbers with many digits.
- ›Bit length display: shows how many bits are needed to represent the value.
Formula
| Base | Name | Digits | Common Use |
|---|---|---|---|
| 2 | Binary | 0, 1 | CPU logic, memory addressing, network masks |
| 8 | Octal | 0–7 | Unix file permissions (chmod 755) |
| 10 | Decimal | 0–9 | Human arithmetic, everyday numbers |
| 16 | Hex | 0–9, A–F | Memory addresses, color codes (#FF5733), byte values |
| 32 | Base-32 | 0–9, A–V | Encoding (Base32 in TOTP/MFA tokens) |
| 36 | Base-36 | 0–9, A–Z | URL shorteners, unique identifiers |
How to Use
- 1Select the input base using the preset buttons (Binary, Octal, Decimal, Hex) or enter a custom base.
- 2Type your number in the input field. For bases > 10, use letters A–Z (automatically uppercased).
- 3Select the target base using the "Convert to" buttons or enter a custom base.
- 4Click Convert or press Enter to see results in all four standard bases plus your custom target.
- 5Use the Copy buttons to copy any individual result.
- 6The division steps table below shows the algorithm used for the conversion.
- 7Click Clear to reset all inputs.
Example Calculation
Example, 255 (decimal) to all bases
Example, Converting from Binary
Hexadecimal in programming
Understanding Number Base Converter | Binary, Hex
How Positional Numeral Systems Work
Every positional numeral system represents a number as a sum of digits multiplied by powers of the base. In decimal (base 10), 345 means 3×10² + 4×10¹ + 5×10⁰ = 300 + 40 + 5. The same principle applies in any base: binary 1011 means 1×2³ + 0×2² + 1×2¹ + 1×2⁰ = 8 + 0 + 2 + 1 = 11 (decimal).
The digits in each base are the integers from 0 to base−1. For bases beyond 10, letters supplement the digits: base 16 uses A=10, B=11, C=12, D=13, E=14, F=15. Base 36 extends to Z=35. Any representation up to base 36 can be handled with the 36 characters 0–9 and A–Z.
Binary and Hexadecimal in Computing
Binary is the native language of digital computers because transistors have two states, on (1) and off (0). All data in a computer is ultimately binary: text, images, audio, machine code. However, binary numbers become unwieldy for humans (255 decimal = 11111111 binary). Hexadecimal was adopted as a human-friendly shorthand: each hex digit represents exactly 4 binary bits (a nibble), so 2 hex digits perfectly represent one byte.
- ›Memory address 0x1A3F: each byte is two hex digits; 0x prefix indicates hex in code.
- ›Color #FF5733: FF=255 red, 57=87 green, 33=51 blue, each channel 0–255.
- ›IPv4 subnet mask: 255.255.255.0 = FF.FF.FF.00 in hex.
- ›ASCII table: character A = decimal 65 = hex 41 = binary 01000001.
Octal and Unix File Permissions
Octal (base 8) groups binary into 3-bit chunks instead of 4. Each octal digit represents 3 bits, making it useful in contexts where data is naturally organized in 3-bit groups. The most prominent example is Unix/Linux file permissions: chmod 755 sets permissions to rwxr-xr-x. Each digit is an octal representation of a 3-bit permission group (owner, group, other): 7 = 111 = rwx, 5 = 101 = r-x.
- ›chmod 644 → rw-r--r-- (6=110=rw-, 4=100=r--, 4=100=r--)
- ›chmod 777 → rwxrwxrwx (7=111=rwx for all three)
- ›chmod 400 → r-------- (owner read only)
The Division Algorithm for Base Conversion
To convert a decimal number to base b, repeatedly divide by b and record remainders. The remainders, read from last to first, give the representation in base b. For 255 → binary: 255÷2=127 rem 1, 127÷2=63 rem 1, …, 1÷2=0 rem 1. Remainders bottom-up: 11111111. This calculator shows every division step, an excellent way to understand the algorithm for exams and programming interviews.
Frequently Asked Questions
How do I convert a number from decimal to binary?
Use the repeated division by 2 method. Divide the decimal number by 2 repeatedly, recording the remainder each time. When the quotient reaches 0, read the remainders from bottom to top.
This calculator performs these steps automatically and displays the complete division table, making it easy to follow and verify the conversion.
Why is hexadecimal used in programming?
Hexadecimal (base 16) is used because it is compact and maps directly to binary: one hex digit = exactly 4 binary bits (a nibble), two hex digits = one byte (8 bits). This makes it much easier to read binary values than counting 8 zeros and ones.
- ›255 decimal = FF hex = 11111111 binary, 2 hex digits vs 8 binary digits
- ›Memory addresses: 0x00BFFF is far cleaner than its 18-digit binary equivalent
- ›Color codes: #FF0000 = full red (255, 0, 0), intuitive in 6 hex digits
- ›Bitwise AND/OR/XOR operations are easiest to reason about in hex
What bases are used in practice beyond binary, octal, decimal, and hex?
Several other bases have practical applications:
- ›Base 32: used in TOTP authentication tokens, IPFS content identifiers, Crockford encoding.
- ›Base 36 (0–9, A–Z): URL shorteners, unique identifiers (case-insensitive, alphanumeric only).
- ›Base 60 (sexagesimal): used by Babylonians, survives in time (60 seconds, 60 minutes) and angles (360°).
- ›Base 12 (duodecimal): proposed as superior to decimal because 12 has more divisors (2,3,4,6) than 10 (2,5).
- ›Base 3 (ternary): proposed for balanced ternary computing (−1, 0, +1 digits).
How do I convert from binary to hexadecimal without going through decimal?
Group the binary number into groups of 4 bits from right to left, then convert each group to its hex equivalent. No intermediate decimal step needed.
This grouping works because 16 = 2⁴, hex and binary are powers of the same base. Similarly, octal groups binary into 3-bit chunks because 8 = 2³.
What are the valid digits for each base?
Each base uses digits from 0 to base−1. For bases above 10, letters supplement:
This calculator accepts uppercase or lowercase input and automatically uppercases it. Entering digits invalid for the selected base produces an error with a specific explanation.
How do Unix file permissions relate to octal?
Unix file permissions are a set of three 3-bit groups: owner, group, and others. Each 3-bit group can be represented as a single octal digit (0–7).
This is why chmod uses 3-digit octal numbers. It is a direct mapping from 9 permission bits to 3 octal digits, no decimal conversion needed.
Can this converter handle very large numbers?
Yes, this calculator uses JavaScript BigInt for conversions, which supports arbitrary-precision integers with no overflow up to 60 input digits. Standard JavaScript numbers (64-bit floating point) lose precision for integers above 2⁵³ ≈ 9 × 10¹⁵, which would corrupt binary representations of large values. BigInt avoids this entirely.
- ›Safe for 64-bit integers (up to 9,223,372,036,854,775,807)
- ›Safe for 128-bit values used in IPv6 addresses and UUIDs
- ›Handles numbers up to 60 digits (input limit)
- ›Results are always exact, no floating-point rounding