Binary / Hex / Octal Converter
Convert numbers between binary, decimal, hexadecimal, and octal instantly. All four bases, bidirectional, with step-by-step breakdown.
How to convert between binary, decimal, hex and octal
Type a number in any base and read it in the other three.
- 01
Type into any of the four boxes
Decimal, binary, hexadecimal or octal. The other three fill in as you type, so you can start from whichever base you have.
- 02
Leave out prefixes
Type FF rather than 0xFF, and 1010 rather than 0b1010. Hex accepts upper or lower case; only decimal accepts a minus sign.
- 03
Copy the base you need
Each box has its own copy button. Binary is padded with leading zeros to whole groups of four bits, at least one byte, with the bit and byte count shown underneath.
How the bases relate
Each base uses a different number of digits. Decimal uses 10, binary 2, octal 8 and hexadecimal 16, with A to F standing for 10 to 15. One hex digit is exactly four binary digits and one octal digit is exactly three, which is why programmers use hex as a short way of writing binary.
| Decimal | Binary | Hex | Octal |
|---|---|---|---|
| 10 | 1010 | A | 12 |
| 15 | 1111 | F | 17 |
| 16 | 1 0000 | 10 | 20 |
| 100 | 110 0100 | 64 | 144 |
| 255 | 1111 1111 | FF | 377 |
| 256 | 1 0000 0000 | 100 | 400 |
| 1,024 | 100 0000 0000 | 400 | 2000 |
| 65,535 | 1111 1111 1111 1111 | FFFF | 177777 |
255, FF in hex, is the largest value in one byte, which is why it appears in colour codes like #FFFFFF and in network masks like 255.255.255.0. A worked conversion: 100 in binary is 64 + 32 + 4 = 1100100.
Big numbers and negative numbers
The converter uses JavaScript's BigInt, so it's exact for any whole number you type, however long. 9,007,199,254,740,993 converts correctly, even though ordinary JavaScript numbers can't hold it exactly and would round it to …992.
Negative decimals are shown with a minus sign in every base: −10 is −1010 in binary and −A in hex. That's the mathematical value, not the two's-complement form a computer stores. In 8-bit two's complement, −10 is 1111 0110; to get that, add 256 to the negative number (−10 + 256 = 246) and convert 246.
Powers of two worth remembering
Binary place values double from right to left: 1, 2, 4, 8, 16 and so on. A handful of them come up so often in computing that they're worth knowing by heart:
| Power | Value | Where you'll see it |
|---|---|---|
| 2⁸ | 256 | Values in one byte (0 to 255); colour channels |
| 2¹⁰ | 1,024 | One kibibyte (KiB) |
| 2¹⁶ | 65,536 | Port numbers (0 to 65,535); 16-bit audio levels |
| 2²⁰ | 1,048,576 | One mebibyte (MiB) |
| 2²⁴ | 16,777,216 | Colours in 24-bit RGB |
| 2³² | 4,294,967,296 | IPv4 addresses; 32-bit integer range |
| 2⁶⁴ | 18,446,744,073,709,551,616 | 64-bit integer range |
To convert decimal to binary by hand, keep dividing by 2 and write down the remainders, then read them from bottom to top. 13 ÷ 2 = 6 r1, 6 ÷ 2 = 3 r0, 3 ÷ 2 = 1 r1, 1 ÷ 2 = 0 r1, giving 1101.
Where base conversion comes up
Reading hex colour values
Convert each pair of a colour code to decimal: #3B82F6 is 59, 130 and 246 for red, green and blue.
Working out permissions and flags
Unix file mode 755 is octal for binary 111 101 101: read, write and execute for the owner, read and execute for everyone else.
Checking homework or exam answers
Type the decimal number and see the binary, octal and hex answers side by side.