🔢 Number Base Converter
Type a number in any box and every other base updates instantly. Pick a bit width to see negative numbers in two's complement, and click bits below to flip them one by one.
How to use the base converter
- Type a number into any field — binary, octal, decimal, hexadecimal or base N. All the other fields update as you type.
- Prefixes like
0b1010,0o17and0xFFare fine, and so are separators:1111 0000,1_000_000and1,000,000all work. Hex digits can be upper- or lowercase. - To see a negative number as bits, choose a bit width (8, 16, 32 or 64). With 32-bit selected,
-1shows asFFFF FFFF. - Click any cell in the bit grid to flip that bit; every base updates with it. Handy for bit flags, masks and Unix permissions like 755.
- Each row's copy button copies the value without spaces or commas. Turn on "add 0b / 0o / 0x when copying" to paste straight into code.
How base conversion works
Base N → decimal: multiply each digit by N raised to its position and add them up. Hex 2F = 2×16 + 15 = 47. Binary 101101 = 32 + 8 + 4 + 1 = 45.
Decimal → base N: divide by N repeatedly and read the remainders from bottom to top. 45 ÷ 2 gives remainders 1, 0, 1, 1, 0, 1 → reversed, 101101.
Binary ↔ hex and octal is even easier. Since 16 = 2⁴, every 4 binary digits make one hex digit; since 8 = 2³, every 3 make one octal digit. 1011 0110 → B6. That's why this tool groups binary and hex in fours.
| Decimal | Binary | Octal | Hex |
|---|---|---|---|
| 0 | 0000 | 0 | 0 |
| 1 | 0001 | 1 | 1 |
| 7 | 0111 | 7 | 7 |
| 8 | 1000 | 10 | 8 |
| 10 | 1010 | 12 | A |
| 15 | 1111 | 17 | F |
| 16 | 1 0000 | 20 | 10 |
| 100 | 0110 0100 | 144 | 64 |
| 255 | 1111 1111 | 377 | FF |
| 1024 | 0100 0000 0000 | 2000 | 400 |
| 65535 | 1111 1111 1111 1111 | 177777 | FFFF |
Negative numbers and two's complement
Computers almost always store negative integers in two's complement. In n bits, −x is stored as the bit pattern of 2ⁿ − x. So in 8 bits, −1 is 256 − 1 = 255 = 1111 1111, and −128 is 1000 0000. If the leftmost bit (MSB) is 1, the number is negative. The shortcut: invert all bits and add 1.
| Width | Signed range | Unsigned range | Common types |
|---|---|---|---|
| 8-bit | −128 to 127 | 0 to 255 | int8 / sbyte, uint8 / byte |
| 16-bit | −32,768 to 32,767 | 0 to 65,535 | short, uint16 |
| 32-bit | −2,147,483,648 to 2,147,483,647 | 0 to 4,294,967,295 | int, uint32 |
| 64-bit | about −9.22×10¹⁸ to 9.22×10¹⁸ | 0 to 18,446,744,073,709,551,615 | long / int64, uint64 |
With a bit width selected, values typed into the binary, octal or hex fields are read as a bit pattern. For example, with 8-bit signed, hex 80 is −128 in decimal; untick "signed" and it's 128. The bits stay the same — only the interpretation changes. Values outside the range show a warning and only the low n bits are kept, exactly like a real overflow.
What's supported
- Integers only, computed with JavaScript BigInt, so numbers beyond 2⁵³ (the 64-bit maximum, or hundreds of digits) convert exactly with no rounding. The bit grid draws up to 256 bits.
- No fractions. Decimal fractions like 0.1 usually become infinite repeating binary fractions. To convert one by hand, keep multiplying the fractional part by 2 and write down the integer part each time (0.625 → 1.25 → 0.5 → 1.0 →
0.101). IEEE 754 float/double storage is outside this tool's scope. - Base N covers bases 2–36, using a–z (case-insensitive) for digits 10 and up. Base 36 is popular for short IDs and URL shorteners.
All calculations run in your browser. Regular JavaScript Numbers lose accuracy above 2⁵³ (9007199254740993 becomes …992), but this converter uses BigInt and keeps every digit.