Online Number Base Converter (Binary / Octal / Decimal / Hexadecimal)
Online Number Base Converter (Binary / Octal / Decimal / Hexadecimal): Detect 0x, 0b, and 0o Prefixes, Calculate BigInts Precisely, and Handle Permissions and Colors
How does the number base converter work? See all four bases from one number
A number base converter converts the same integer between binary, octal, decimal, and hexadecimal representations.
Select an input base or enter a 0x, 0b, or 0o prefix directly. The tool then shows all four results. All calculations run locally in the browser.
What are the four number bases used for?
Binary is used for bit operations, permission masks, and hardware registers; octal is most commonly used for Linux file permissions such as 755 and 644; decimal is used for everyday counting; hexadecimal is used for colors, memory addresses, hash fragments, and protocol data. They are simply different representations of the same value.
There is also a useful rule: one hexadecimal digit corresponds exactly to four binary bits. Expanding hexadecimal digits into binary is therefore much faster than reading a long binary value directly when checking masks and permission bits.
Do I still need to select a base when the input has a 0x, 0b, or 0o prefix?
No. With automatic prefix detection enabled, 0xff is parsed as hexadecimal, 0b1010 as binary, and 0o755 as octal, and the input-base selector switches automatically. Without automatic detection, the current selected base is used. Results include prefixes by default for easy pasting into code, and the option can be disabled when not needed. Hexadecimal output is uppercase by default, while both uppercase and lowercase input are accepted.
Why do large integers not lose precision?
The tool uses BigInt for exact integer arithmetic. Large integers greater than 2 to the power of 53, such as Snowflake IDs and hash fragments, do not suffer from last-digit rounding. JavaScript Number values provide only 53 bits of integer precision, so ordinary floating-point conversion can silently produce incorrect results for such values.
How can long binary values be checked quickly?
Enable grouping by four bits to insert spaces every four bits. This makes the relationship with hexadecimal immediately visible: every four binary bits correspond to one hexadecimal digit. The expandable number information also shows the decimal value and binary bit length, so you do not have to count the width manually.
The reverse check works the same way: group the binary value from right to left into four-bit sections and convert each section directly into a hexadecimal digit without going through decimal.
Common errors and limitations
Two common errors are selecting the wrong base, such as interpreting decimal 255 as hexadecimal and obtaining 597, and entering characters that are invalid for the selected base, such as 2 in binary or 8 in octal. The tool immediately identifies invalid characters instead of returning an apparently correct result. It handles integers only and supports negative numbers. Fractions require separate conversion. Results contain no thousands separators, making them easier to paste into code.
How do you use values such as permission 755 and color #FF0000?
Interpret 755 as octal to obtain decimal 493 and binary 111101101, corresponding to read, write, and execute permissions for the owner, read and execute for the group, and read and execute for others. Convert hexadecimal FF0000 to decimal 16711680 and split it into three bytes, 255, 0, and 0, which are the red, green, and blue components. The tool makes these conversions easy to inspect in one place.
What is the difference between binary, octal, decimal, and hexadecimal?
They are simply different representations of the same numeric value: binary uses 0 and 1, octal uses 0 through 7, decimal uses 0 through 9, and hexadecimal uses 0 through 9 plus A through F. Changing the base does not change the value, so conversion changes only the notation and does not inherently cause precision loss when exact integer arithmetic is used.
In practice, binary is useful for bit operations and permission masks, octal for Linux file permissions, hexadecimal for colors and memory addresses, and decimal for everyday counting.
- One input produces binary, octal, decimal, and hexadecimal results at the same time, and each result can be copied separately.
- Automatically detects 0x, 0b, and 0o prefixes and switches the input base, while manual base selection is also supported.
- Uses BigInt for exact integer arithmetic, so integers greater than 2 to the power of 53 do not lose precision.
- Optional four-bit grouping makes binary-to-hexadecimal comparison easier, and output prefixes can be enabled or disabled.
- Expandable number information shows the decimal value and binary bit length. Bit length uses the minimum number of binary bits; zero has 0 bits and negative numbers use their absolute value.
- Invalid characters for the selected base are explicitly identified instead of producing an apparently valid result. Only integers are supported, including negative numbers.