Number Base Converter
Convert between binary, octal, decimal, and hexadecimal number systems.
Convert between binary, octal, decimal, and hexadecimal number systems.
Every number system is positional: the value of a digit depends on where it sits. The integer part of a number is the sum of each digit multiplied by the base raised to its position, counting from zero at the right. To convert, the tool parses the cleaned input into a JavaScript number and re-encodes it in the target base. Fractions are handled separately. Each fractional digit is worth that digit divided by the base raised to its position, and to emit the result the tool repeatedly multiplies the fraction by the target base, takes the whole part as the next digit, and keeps the remainder. That repeated multiplication is why non-terminating fractions get cut off.
Before any of this, the input is cleaned: underscores, commas, and spaces are removed, and letters are uppercased. That lets you paste grouped binary like 1111_0000 or formatted decimal like 1,024 without pre-processing.
Simple integer. Decimal 255 becomes binary 11111111, octal 377, and hex FF. Reading it back: 255 is 2^8 - 1, so binary is eight ones and hex uses two F digits, each worth 15.
Hex with letters. Hex 1A4 becomes decimal 420. Check it: 1 x 256 + 10 x 16 + 4 = 420. In binary that is 110100100 and in octal 644.
A fraction that repeats. Decimal 0.1 becomes binary 0.00011001, octal 0.06314631, and hex 0.19999999. All three are truncated approximations of a value that has no exact finite form in those bases.
A binary fraction. Binary 1010.101 becomes decimal 10.62500000, octal 12.5, and hex A.A. The fractional part .101 is 1/2 + 0/4 + 1/8 = 0.625.
| Base | Digits | Prefix for output |
|---|---|---|
| Binary (2) | 0-1 | 0b |
| Octal (8) | 0-7 | 0o |
| Decimal (10) | 0-9 | none |
| Hexadecimal (16) | 0-9, A-F | 0x |
The prefix buttons add a decoration to the copied result. They only apply to the result row whose base matches the base you selected on the input side. For example, if you enter a hexadecimal value and choose 0x, only the hexadecimal row is prefixed; the binary, octal, and decimal rows stay plain. Switch the input base and the prefix moves with it, because it is always tied to the source base, not applied globally.
0.5 shows as 0.50000000; other bases trim trailing zeros.000255 converts the same as 255.10 in binary as ten. It is two; the digit positions are powers of two.0x1F fails in the hex field because x is not a hex digit; enter 1F and use the toggle.1,5 is read as 15, not 1.5.Web color channels. A CSS hex color such as FF5733 is three bytes written in base 16. Convert each pair separately by entering FF, 57, and 33 with the base set to hexadecimal: they become decimal 255, 87, and 51, which is exactly the RGB triplet. The tool converts the whole value, so split the six-digit string into pairs first.
Unix file permissions. Permission modes like 755 are read in octal, not decimal. Convert 755 from base 8 and you get binary 111101101, which groups as 111 (read, write, execute) for the owner, 101 for the group, and 101 for others. Decimal 493 is the same value, which is why a permissions calculator is a better fit for that specific job.
Bitmasks and flags. A mask written as binary 00001111 is decimal 15 and hex F. Converting between these makes it easier to reason about which bits are set.
Debugger addresses. A crash log might show address 0x7FFE0A10. Convert it from hex to decimal 2147352592 or to binary when you need to inspect individual bits.
Two shortcuts let you verify the tool’s output quickly. To go from binary to hex, group the bits into nibbles of four from the right and convert each nibble: 110100100 becomes 1 | 1010 | 0100, which is 1A4. To go from binary to octal, group into threes instead: 110 | 100 | 100 becomes 644. Both match the earlier example, so if your manual grouping disagrees with the converter, recheck where you started grouping. Remember to group from the right, and pad the leftmost group with zeros only if you need a fixed width.
Because one tenth has no exact representation in base two. Converting a fraction means repeatedly multiplying by the target base and collecting the whole parts, and 0.1 produces the repeating sequence 0001100110011... forever. The converter stops after eight fractional digits and truncates rather than rounds, so the binary output is 0.00011001. The same limit means 0.1 in hexadecimal shows as 0.19999999. Fractional results are approximations, not exact values.
No. The minus sign is not a valid digit in any of the four supported bases, so a value like -5 is rejected with an invalid-input error. The converter handles magnitudes only. If you need sign handling, strip the minus, convert the magnitude, and add the sign back in your own code.
No. The prefix buttons control whether the copied output is decorated for use in source code; they do not enable prefix parsing on input. Typing 0x1F into a hexadecimal field fails because the x is not a hex digit. Enter the digits only, and use the toggle to add a prefix to the result you copy.
Fractional conversion works by producing eight target-base digits and, for the decimal row specifically, the code keeps all eight rather than trimming trailing zeros. So a simple value like 0.5 appears as 0.50000000 and 10.625 as 10.62500000. For the binary, octal, and hex rows the trailing zeros are stripped, so the binary row shows 0.1 for the same input.
Integer conversion routes through JavaScript numbers, so values are exact only up to 2^53 - 1, which is 9,007,199,254,740,991. Beyond that the intermediate decimal value is rounded and the digits you get back in other bases may not match the original. For very large integers, use a language with arbitrary-precision integers or a dedicated big-number library.
The tool normalizes input and output to uppercase for consistency. It also strips underscores, commas, and spaces before parsing, so you can paste a grouped value like 1111_0000 or 1,024 and it will convert cleanly. Case does not affect the value: ff and FF both mean 255.
Reviewed by the HandyTools Hub team · Last updated