~ / developer / number-base-converter

🔢 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.

number
Examples:
options
Bit width
Interpretation
Display
bits — click to toggle 0/1
info

How to use the base converter

  1. Type a number into any field — binary, octal, decimal, hexadecimal or base N. All the other fields update as you type.
  2. Prefixes like 0b1010, 0o17 and 0xFF are fine, and so are separators: 1111 0000, 1_000_000 and 1,000,000 all work. Hex digits can be upper- or lowercase.
  3. To see a negative number as bits, choose a bit width (8, 16, 32 or 64). With 32-bit selected, -1 shows as FFFF FFFF.
  4. 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.
  5. 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.

DecimalBinaryOctalHex
0000000
1000111
7011177
81000108
10101012A
15111117F
161 00002010
1000110 010014464
2551111 1111377FF
10240100 0000 00002000400
655351111 1111 1111 1111177777FFFF

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.

WidthSigned rangeUnsigned rangeCommon types
8-bit−128 to 1270 to 255int8 / sbyte, uint8 / byte
16-bit−32,768 to 32,7670 to 65,535short, uint16
32-bit−2,147,483,648 to 2,147,483,6470 to 4,294,967,295int, uint32
64-bitabout −9.22×10¹⁸ to 9.22×10¹⁸0 to 18,446,744,073,709,551,615long / 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

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.

FAQ

How do I convert decimal to binary?
Divide by 2 repeatedly and read the remainders from bottom to top: 13 ÷ 2 = 6 r1, 6 ÷ 2 = 3 r0, 3 ÷ 2 = 1 r1, 1 ÷ 2 = 0 r1 → 1101. Or type 13 in the decimal field above.
How do I convert binary to hex?
Split the binary number into groups of 4 digits from the right and convert each group to one hex digit: 1011 0110 → B and 6 → B6. Paste the binary into the binary field to do it instantly.
What is FF in decimal?
F is 15, so FF = 15×16 + 15 = 255. In binary that is 1111 1111 (all 8 bits set). Each pair in a color code like #FFFFFF is one of these 0–255 values.
How are negative numbers represented in binary?
With two's complement in a fixed bit width: invert every bit and add 1. 8-bit 5 is 0000 0101 → invert to 1111 1010 → add 1 = 1111 1011, which is −5. Set the width to 8-bit and type −5 to see it.
What do the 0x, 0b and 0o prefixes mean?
They mark the base in most programming languages: 0x is hexadecimal, 0b is binary and 0o is octal. This tool accepts them on input and can add them when you copy.
What does chmod 755 mean in binary?
Octal 755 is 111 101 101 in binary. Each group of three is read (4), write (2) and execute (1) for owner, group and others — so the owner gets rwx and everyone else r-x. Type 755 in the octal field and look at the bit grid.

Related tools