NetCalcLab

IP to Binary Converter

Convert an IPv4 address to its 32-bit binary form. The result is shown both octet by octet and as one continuous 32-bit string, so you can see exactly where each byte boundary falls.

Enter a dotted-decimal address. Leading zeros in an octet are rejected because they are ambiguous.

Examples:

How the conversion works

An IPv4 address is four decimal numbers separated by dots, and each of those numbers is one byte — eight bits. Converting to binary therefore means converting four independent numbers between 0 and 255 into 8-bit values, one at a time. There is no carry between octets and no interaction between them.

Place values inside one octet
Bit position   1    2    3    4    5   6   7   8
Place value  128   64   32   16    8   4   2   1
              ---   --   --   --   --   -   -   -
Set bits:     1     1    0    0    0   0   0   0   -> 128 + 64 = 192

To convert by hand, compare the remaining number against each place value in turn. If it is greater than or equal to the place value, write a 1 and subtract; otherwise write a 0 and move on.

Example: 172.16.5.20 to binary

172 → 10101100
16  → 00010000
5   → 00000101
20  → 00010100

Taking 172: 172 ≥ 128 gives 1 with 44 remaining; 44 < 64 gives 0; 44 ≥ 32 gives 1 with 12 remaining; 12 < 16 gives 0; 12 ≥ 8 gives 1 with 4 remaining; 4 ≥ 4 gives 1 with 0 remaining; and the last two bits are 0. The result is 10101100, and the check is 128 + 32 + 8 + 4 = 172.

Full address: 10101100.00010000.00000101.00010100

Where the network boundary falls

Binary is most useful when you add the mask. Writing the mask underneath the address and drawing a line at the prefix length shows the split immediately.

192.168.1.10/24
Address   11000000.10101000.00000001.00001010
Mask      11111111.11111111.11111111.00000000
          |<------ network 24 bits ---->|<- host ->|
Network   11000000.10101000.00000001.00000000   (192.168.1.0)
Broadcast 11000000.10101000.00000001.11111111   (192.168.1.255)

The network address is the address with every host bit forced to 0, and the broadcast address is the address with every host bit forced to 1. Both operations are single bitwise AND and OR against the mask, which is exactly how routers and hosts compute them.

Common mistakes

  • Dropping leading zeros. 10.0.0.1 is 00001010.00000000.00000000.00000001, not 1010.0.0.1. Pad every octet to eight bits before joining.
  • Reversing the bit order. The leftmost bit is the most significant one and carries 128, not 1. Reversing the order gives a plausible but wrong answer.
  • Treating the address as one 32-bit number and converting that. The arithmetic works out identically, but you lose the octet boundaries that make the network/host split readable.
  • Forgetting that 255 is all ones. A broadcast address ending in .255 is all-ones in the last octet, which is why it is the top of the block.

Other conversions: Binary to IP Converter · IP to Hex Converter · Hex to IP Converter · IP to Decimal Converter · Decimal to IP Converter

Reference: octets to binary

The nine values that can appear in a subnet mask octet, plus a few common octets that show up in addresses.

Decimal octets and their binary forms
DecimalBinaryHexTypical use
00000000000Mask host octet, unspecified address
10000000101First host in a subnet
10000010100ASecond octet of the 10.0.0.0/8 private block
1281000000080/25 subnet mask octet
16810101000A8Second octet of 192.168.x.x
19211000000C0/26 mask octet; also 192.168.x.x first octet
22411100000E0/27 mask octet; start of multicast range
24011110000F0/28 mask octet
24811111000F8/29 mask octet
25211111100FC/30 mask octet
25411111110FE/31 mask octet
25511111111FF/32 mask octet, broadcast octet

This page is one of a set: convert back with binary to IP, or work with hexadecimal, decimal and the full IP converter.

Frequently asked questions

How do I convert an IP address to binary?

Convert each of the four octets to an 8-bit binary number and keep the dots between them. For 192.168.1.1, the octets 192, 168, 1 and 1 become 11000000, 10101000, 00000001 and 00000001, giving 11000000.10101000.00000001.00000001. Removing the dots gives the same 32 bits as one continuous string.

Why are there always 32 bits?

An IPv4 address is exactly 32 bits wide, split into four 8-bit octets. Every octet must be padded to eight digits, so the address 1.1.1.1 becomes 00000001.00000001.00000001.00000001 — not 1.1.1.1 in binary. Missing leading zeros are the single most common hand-conversion error, because dropping them makes the boundaries between octets ambiguous.

What are the binary place values within an octet?

From left to right they are 128, 64, 32, 16, 8, 4, 2 and 1. Add up the place values where a 1 appears to get the decimal octet, and the maximum is 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = 255, which is why octets never exceed 255.

How do I know where the network part ends?

The prefix length tells you. In 192.168.1.10/24, the first 24 bits are the network portion and the last 8 are the host portion, so the binary splits as 11000000.10101000.00000001 | 00001010. Everything to the left of the divider identifies the subnet; everything to the right identifies the host within it.

Can I convert an IPv6 address to binary?

Yes, but the result is 128 bits rather than 32, which is why IPv6 addresses are usually shown in hexadecimal groups instead. The IPv6 calculator on this site shows the full 128-bit binary form along with the compressed and expanded hex notation.

Why is binary useful if nobody types it?

Binary makes subnet masks and wildcard masks obvious once you see them. A /26 mask is 255.255.255.192 in decimal, which tells you very little, but as 11111111.11111111.11111111.11000000 you can immediately count 26 ones and see the host boundary. ACL wildcard masks are the complement of that pattern, and reading them in binary is far less error-prone.