Skip to content

Binary to Decimal Converter (Plus Hex & Octal)

Binary to decimal converter that also handles hex and octal. Type in any box and the others update, with exact results for very large numbers.

By Updated Runs in your browser

Binary Decimal Converter guide

Convert between binary, decimal, hexadecimal, and octal in one place. Type in any field and the other three update instantly, with exact precision even for numbers hundreds of digits long.

Place value in base 2

Decimal is base 10: each position is worth ten times the one to its right (ones, tens, hundreds). Binary is base 2: each position is worth twice the one to its right. Reading right to left, the places are 1, 2, 4, 8, 16, 32, 64, 128, and so on. A binary number is just a list of which of those place values are switched on.

So 101010 means 32 + 8 + 2 = 42. And 11111111, eight ones, is 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = 255. That is the largest value one byte can hold, which is why RGB color channels, IPv4 address octets, and old game high scores top out at 255.

Worked example: decimal to binary by hand

Convert 202. Divide by 2 and record the remainder each time: 202 ÷ 2 = 101 r0, 101 ÷ 2 = 50 r1, 50 ÷ 2 = 25 r0, 25 ÷ 2 = 12 r1, 12 ÷ 2 = 6 r0, 6 ÷ 2 = 3 r0, 3 ÷ 2 = 1 r1, 1 ÷ 2 = 0 r1. Read the remainders from the bottom up: 11001010. Check it: 128 + 64 + 8 + 2 = 202.

The other method is subtraction. Find the largest power of 2 that fits (128), subtract it (74 left), then the next that fits (64, leaving 10), then 8 (leaving 2), then 2. Put a 1 in those places and 0 elsewhere. Both methods give the same answer; subtraction is faster for small numbers in your head.

Why hex and octal come along for the ride

Hexadecimal is base 16, using 0 to 9 then A to F for 10 to 15. Because 16 is 2 to the 4th power, every hex digit maps to exactly four bits. 1100 1010 splits into 1100 (C) and 1010 (A), so 202 is CA in hex. That clean mapping is why hex shows up everywhere bits matter: color codes like #CA8A04, memory addresses, MAC addresses, and byte dumps.

Octal is base 8, and each octal digit maps to three bits. You mostly meet it in Unix file permissions. chmod 755 means 111 101 101: read, write, and execute for the owner, and read plus execute for everyone else. The grouped binary display under the converter splits long values into 4-bit nibbles so you can read hex digits straight off it.

Networking example: IP addresses and subnet masks

IPv4 addresses are four bytes written in decimal. 192.168.1.10 is 11000000.10101000.00000001.00001010 in binary. A subnet mask of 255.255.255.0 is 24 ones followed by 8 zeros, which is why it is written /24. The ones mark the network part of the address; the zeros mark the host part, leaving 256 addresses, 254 of them usable.

When a mask looks odd, such as 255.255.255.192, convert the last octet: 192 is 11000000, so the mask is /26 and each subnet holds 64 addresses. The IP subnet calculator does this for whole networks, but understanding the binary makes the results make sense.

Big numbers and negative numbers

Standard JavaScript numbers lose precision above 2^53, which is 9,007,199,254,740,992. Many online converters silently round beyond that, so 2^53 + 1 comes back as 2^53. This converter uses BigInt arithmetic, so a 64-bit ID, a 256-bit hash value, or a hundred-digit number converts exactly.

Negative numbers are shown with a minus sign in front of the magnitude: -42 is -101010. Real hardware uses two's complement instead, where the bit pattern depends on the width. In 8 bits, -42 is 11010110: invert 00101010 and add 1. If you need two's complement, convert the positive value, pad to your width, invert every bit, and add one.

Mistakes that trip people up

Reading binary left to right from the wrong end. The rightmost bit is always the ones place. Dropping leading zeros is fine for value but not for fixed-width fields; the byte 00001010 and the number 1010 are equal, yet a protocol expecting eight bits needs all eight.

Mixing up bases in notation is another. Code often marks them with prefixes: 0b for binary, 0x for hex, 0o for octal. The converter accepts those prefixes and ignores spaces and underscores, so you can paste 0b1100_1010 or 0xCA directly.

How we calculate: sources

Frequently asked questions

How do you convert binary to decimal?

Multiply each bit by its power of 2 and add them up, starting from the right at 2^0. For 101010: 32 + 0 + 8 + 0 + 2 + 0 = 42.

How do you convert decimal to binary?

Divide by 2 repeatedly and write down the remainders, then read them bottom to top. 42 ÷ 2 gives remainders 0, 1, 0, 1, 0, 1, which read upward is 101010.

What is 255 in binary?

11111111, eight ones. It is the largest value that fits in one byte, and FF in hexadecimal. That is why RGB color channels and IPv4 address octets run from 0 to 255.

Why do programmers use hexadecimal?

Each hex digit maps to exactly 4 bits, so a byte is always two hex digits. 11111111 is FF, and a 32-bit value is 8 hex digits instead of 32 ones and zeros.

How are negative numbers shown in binary?

Computers usually use two's complement, where -1 in 8 bits is 11111111. This converter shows a minus sign in front of the magnitude instead (-42 is -101010), since two's complement depends on the bit width.

Is there a size limit?

No practical one. The converter uses JavaScript BigInt, so it stays exact past 2^53 (9,007,199,254,740,992), where regular number converters start rounding.

Is anything uploaded?

Everything runs in your browser. Nothing you enter is uploaded to a server or stored by us.

What is 10 in binary?

1010. That is 8 + 2. In hexadecimal, 10 is A.