📊 CIDR Calculator

Convert between CIDR notation and subnet masks to better understand network ranges and IP addressing.

💡 Tip: Enter CIDR notation and click "Calculate CIDR" to convert to subnet mask format.
Enter CIDR notation and click "Calculate CIDR" to view results.

From a prefix to a mask

A prefix is just an instruction to build a 32-bit mask by shifting a full row of 1 bits left, so the low bits fall away and become the host part:

mask      = 0xFFFFFFFF << (32 - prefix)
network   = ip AND mask
broadcast = network OR (NOT mask)
addresses = 2^(32 - prefix)

Enter 10.20.30.44/27. Shifting left by 5 leaves 0xFFFFFFE0, which is 255.255.255.224. In the last octet 44 is 00101100 and 224 is 11100000, so the network is 10.20.30.32; NOT 224 is 31, and 32 OR 31 is 63, so the broadcast is 10.20.30.63. Five host bits give 32 addresses and 30 usable ones, .33 to .62.

Aggregating blocks into one prefix

Blocks only merge when they are adjacent and the shorter prefix lands on its own boundary. Four consecutive /24s, 192.168.4.0 through 192.168.7.0, collapse into 192.168.4.0/22: the /22 mask is 255.255.252.0, and 4, 5, 6 and 7 all AND with 252 to give 4, so all four share one network address.

The input needs a full address and a prefix. A bare /24 is rejected because there is nothing to the left of the slash to parse, and /0 is accepted but returns a 255.255.255.255 mask rather than 0.0.0.0.

Frequently asked questions

What is /27 as a subnet mask?

255.255.255.224. Twenty-seven 1 bits fill three octets plus the top three of the fourth, and 11100000 is 224. The block holds 32 addresses, 30 of them usable.

How many IP addresses are in a /22?

1,024 addresses, of which 1,022 are usable hosts. A /22 has 10 host bits, and 2^10 is 1,024 - the same as four /24 blocks side by side.

Can any two subnets be combined into one CIDR block?

No. They must be the same size, next to each other, and the lower one must start on a boundary of the combined size. 10.0.2.0/24 and 10.0.3.0/24 merge into 10.0.2.0/23; 10.0.3.0/24 and 10.0.4.0/24 cannot.