Free tool
Binary converter: binary, decimal, hex and octal
Type a number and get it in binary, octal, decimal and hex at once, or pick any base from 2 to 36. Big numbers stay exact, fractions show their repeating digits, and negative numbers come with their two’s complement bits.
Free · no sign-up · runs in your browser, nothing is uploaded
111 1110 1010
11 bits
Binary (2)
111 1110 1010
Octal (8)
3752
Decimal (10)
2,026
Hex (16)
7EA
- 16-bit pattern
- 0000 0111 1110 1010
- hex
- 0x07EA
- bytes, big-endian
- 07 EA
- bytes, little-endian
- EA 07
- as unsigned
- 2026
- as signed
- 2026
Click a bit to flip it. The numbers under each byte are bit positions (0 is the lowest bit).
Divide the whole part (2026) by 2 again and again until the quotient is 0. The remainders, read from the bottom up, are the binary digits.
| divide | quotient | remainder |
|---|---|---|
| 2026 ÷ 2 | 1013 | 0 |
| 1013 ÷ 2 | 506 | 1 |
| 506 ÷ 2 | 253 | 0 |
| 253 ÷ 2 | 126 | 1 |
| 126 ÷ 2 | 63 | 0 |
| 63 ÷ 2 | 31 | 1 |
| 31 ÷ 2 | 15 | 1 |
| 15 ÷ 2 | 7 | 1 |
| 7 ÷ 2 | 3 | 1 |
| 3 ÷ 2 | 1 | 1 |
| 1 ÷ 2 | 0 | 1 |
Bottom up: 11111101010
Result: 11111101010 (binary)
How number bases work
A base (or radix) is how many different digits a number system uses. Decimal has ten (0-9), binary two (0 and 1), octal eight (0-7) and hexadecimal sixteen (0-9 and A-F). Each position is worth the base times the position to its right. In decimal the places are 1, 10, 100; in binary they are 1, 2, 4, 8; in hex 1, 16, 256.
So 1011 in binary is 1×8 + 0×4 + 1×2 + 1×1 = 11, and B in hex is also 11. The value is the same; only the way it is written changes. Programmers use hex because one hex digit is exactly four bits, so a byte is always two hex digits.
| dec | binary | octal | hex |
|---|---|---|---|
| 0 | 0000 | 0 | 0 |
| 1 | 0001 | 1 | 1 |
| 2 | 0010 | 2 | 2 |
| 3 | 0011 | 3 | 3 |
| 4 | 0100 | 4 | 4 |
| 5 | 0101 | 5 | 5 |
| 6 | 0110 | 6 | 6 |
| 7 | 0111 | 7 | 7 |
| 8 | 1000 | 10 | 8 |
| 9 | 1001 | 11 | 9 |
| 10 | 1010 | 12 | A |
| 11 | 1011 | 13 | B |
| 12 | 1100 | 14 | C |
| 13 | 1101 | 15 | D |
| 14 | 1110 | 16 | E |
| 15 | 1111 | 17 | F |
Three ways to convert between bases
Any base to decimal: multiply each digit by its place value and add. 7DE in hex is 7×256 + 13×16 + 14 = 2014. The hex to decimal and binary to decimal pages walk through this for those bases.
Decimal to any base: divide by the base, keep the remainder, and repeat with the quotient until it is 0. The remainders read from the last to the first are the digits. See decimal to binary for the steps in detail.
Binary, octal and hex between each other: no arithmetic needed. Each hex digit is 4 bits and each octal digit is 3 bits, so you group the bits from the right and swap each group for its digit. 1011 0110 is B6 in hex; 10 110 110 is 266 in octal.
Negative numbers and two’s complement
Written by hand, a negative binary number just gets a minus sign: -10 is -1010. Inside a computer, integers have a fixed width (8, 16, 32 or 64 bits) and negatives are stored in two’s complement: invert every bit of the positive value and add 1.
| Decimal | 8-bit two’s complement | Hex |
|---|---|---|
| 127 | 0111 1111 | 7F |
| 1 | 0000 0001 | 01 |
| 0 | 0000 0000 | 00 |
| -1 | 1111 1111 | FF |
| -5 | 1111 1011 | FB |
| -128 | 1000 0000 | 80 |
The top bit tells you the sign. The same 8 bits 11111111 are 255 to an unsigned byte and -1 to a signed one; the bits do not say which. The converter shows both readings, and you can click any bit in the grid to flip it.
Convert number bases in code
JavaScript. toString(radix) and parseInt(string, radix) take any base from 2 to 36. Plain numbers lose precision above 2^53 - 1 (9,007,199,254,740,991), so use BigInt for anything larger.
(255).toString(2); // '11111111'
(255).toString(16); // 'ff'
parseInt('ff', 16); // 255
parseInt('11111111', 2); // 255
BigInt('0xFFFFFFFFFFFFFFFF').toString(10); // '18446744073709551615' (exact)
parseInt('FFFFFFFFFFFFFFFF', 16); // 18446744073709552000 (rounded)Python. int() takes a base from 2 to 36, or 0 to read the prefix. bin(), oct() and hex() go the other way, and integers never overflow.
int('ff', 16) # 255
int('0b1010', 0) # 10, base from the prefix
bin(10), hex(255) # ('0b1010', '0xff')
format(10, '08b') # '00001010'Go
n, _ := strconv.ParseInt("ff", 16, 64) // 255
strconv.FormatInt(255, 2) // "11111111"
fmt.Sprintf("%08b %x %o", 10, 255, 8) // "00001010 ff 10"Bash
echo $((16#FF)) # 255 echo $((2#1010)) # 10 printf '%x\n' 255 # ff echo "obase=2; 10" | bc # 1010
Powers of two worth knowing
Place values in binary are powers of two, and so are most limits you meet in code: 2^8 values in a byte, 2^31 - 1 as the largest signed 32-bit integer, 2^53 as the edge of exact integers in a JavaScript number.
| power | decimal | hex |
|---|---|---|
| 2^0 | 1 | 0x1 |
| 2^1 | 2 | 0x2 |
| 2^2 | 4 | 0x4 |
| 2^3 | 8 | 0x8 |
| 2^4 | 16 | 0x10 |
| 2^5 | 32 | 0x20 |
| 2^6 | 64 | 0x40 |
| 2^7 | 128 | 0x80 |
| 2^8 | 256 | 0x100 |
| 2^10 | 1,024 | 0x400 |
| 2^12 | 4,096 | 0x1000 |
| 2^15 | 32,768 | 0x8000 |
| 2^16 | 65,536 | 0x10000 |
| 2^20 | 1,048,576 | 0x100000 |
| 2^24 | 16,777,216 | 0x1000000 |
| 2^31 | 2,147,483,648 | 0x80000000 |
| 2^32 | 4,294,967,296 | 0x100000000 |
| 2^53 | 9,007,199,254,740,992 | 0x20000000000000 |
| 2^63 | 9,223,372,036,854,775,808 | 0x8000000000000000 |
| 2^64 | 18,446,744,073,709,551,616 | 0x10000000000000000 |
For subnet masks, which are binary too, use the subnet calculator. To turn letters into bits, use text to binary. More command-line helpers are in the CLI tools on DevHunt.
More free developer tools
FAQ
How do I convert binary to decimal?+
Multiply each bit by its place value (1, 2, 4, 8, 16 and so on, from the right) and add the results. 1011 is 8 + 0 + 2 + 1 = 11. Pick Binary as "From" and Decimal as "To" above to see the full working for any number.
What is 11111111 in decimal?+
255. It is eight 1 bits: 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1. It is the largest value one unsigned byte can hold, and FF in hex. Read as a signed 8-bit number (two’s complement), the same bits mean -1.
How do I convert binary to hex?+
Split the binary number into groups of 4 bits from the right, pad the leftmost group with zeros, and replace each group with one hex digit: 0000 is 0, 1001 is 9, 1010 is A, 1111 is F. So 1011 0110 is B6. The converter shows this grouping when you convert between binary and hex.
What is two’s complement?+
The way computers store negative integers. In N bits, a negative number -x is stored as 2^N - x, which is the same as inverting the bits of x and adding 1. In 8 bits, -1 is 11111111 and -128 is 10000000. Set a width in the "Bits and two’s complement" panel to see any number this way.
Why is 0.1 not exact in binary?+
A fraction ends in binary only when its denominator is a power of two. 0.1 is 1/10, and 10 has a factor of 5, so in binary it repeats forever: 0.0001100110011… Floating-point numbers store a rounded version, which is why 0.1 + 0.2 gives 0.30000000000000004 in JavaScript. Type 0.1 above and the converter shows the repeating part in brackets.
Which bases does this converter support?+
Every base from 2 to 36. Digits above 9 are the letters a to z, the same rule JavaScript, Python and Go use. Numbers are handled as exact big integers, so a 100-digit decimal number converts without rounding.
How many bits does a number need?+
A positive integer n needs floor(log2(n)) + 1 bits: 255 needs 8, 256 needs 9. Signed types need one more bit for the sign, so a signed 8-bit type holds -128 to 127. The converter picks the smallest of 8, 16, 32, 64 and 128 bits that fits.
Sources: MDN: Number.prototype.toString() · MDN: parseInt() · MDN: BigInt · MDN: Number.MAX_SAFE_INTEGER · Python: int() · Go: strconv · GNU bc manual. Checked 2026-10-30.