How to Use This CIDR Calculator
The calculator offers two conversion modes, selectable from the dropdown menu.
- CIDR to IP range: Enter an IP address and prefix length (the number after the slash). The tool will output the network address, broadcast address, subnet mask, network prefix, wildcard mask, and total number of usable hosts within that block.
- IP range to CIDR: Provide the first and last IP addresses of your range. If the range aligns perfectly with CIDR block boundaries, you'll receive a single CIDR notation. If not, the calculator will decompose it into the minimum number of CIDR blocks required to cover that range exactly.
Each conversion displays detailed breakdowns of the underlying subnet mathematics, making it straightforward to understand how the transformation works.
Understanding CIDR Notation
CIDR notation was introduced in 1993 (RFC 1519) to replace the inefficient classful addressing system that wasted millions of IP addresses. It combines an IP address with a prefix length:
- IP address: One of the four octets in standard dotted-decimal form (e.g., 172.16.0.0).
- Prefix length: A number from 0 to 32, representing how many of the 32 bits in the IP address form the fixed network portion. The remaining bits are variable and can be assigned to individual hosts.
For example, in 10.0.0.0/16, the first 16 bits (10.0) identify the network, and the final 16 bits can assign addresses to 65,536 unique hosts. This compact notation eliminated the need for separate subnet mask fields and made IP allocation far more granular and efficient.
CIDR to IP Range Conversion
To extract an IP range from CIDR notation, you perform three steps: calculate the subnet mask from the prefix length, identify the network prefix by applying the mask to the given IP address, and use wildcard bits to determine the first and last usable addresses.
Subnet mask octet = 256 − 2^(8 − bits in octet)
Network prefix = IP address AND Subnet mask
First IP = Network prefix (with all host bits set to 0)
Last IP = Network prefix OR Wildcard mask (all host bits set to 1)
Usable hosts = 2^(32 − prefix length) − 2
Prefix length— The number after the slash in CIDR notation, indicating how many bits define the network portion (0–32).Subnet mask— A 32-bit value where the first n bits are 1 and the remaining bits are 0; used to isolate the network address from an IP.Wildcard mask— The bitwise complement of the subnet mask, showing which bits may vary within the network block.Network prefix— The base IP address of the network, with all host bits zeroed out.
Converting an IP Range to CIDR
Reverse conversion—from IP range to CIDR—is more complex because not every IP range maps neatly to a single CIDR block. The calculator evaluates whether your range aligns with CIDR boundaries.
- Aligned ranges: If the first IP address starts at a network boundary and the last IP ends exactly at a broadcast address, a single CIDR block covers it. For instance, 10.0.0.0 to 10.0.0.31 is perfectly captured by 10.0.0.0/27.
- Unaligned ranges: If the range does not align, the calculator decomposes it into the smallest set of non-overlapping CIDR blocks. The range 10.0.0.1 to 10.0.0.31, for example, requires five separate blocks to cover it completely without gaps or overlap.
The tool performs all alignment checks and decomposition automatically, saving you manual bit-by-bit analysis.
Common CIDR Pitfalls and Best Practices
CIDR math trips up even experienced engineers; avoid these frequent mistakes and design patterns.
- Never forget the network and broadcast addresses — The first IP in a block is the network address and the last is the broadcast address—neither can be assigned to a host. A /24 network contains 256 addresses total, but only 254 are usable for devices (256 − 2).
- Prefix length 31 and 32 have special uses — A /31 (2 addresses, 0 usable by standard rules) is used for point-to-point links and treats both IPs as usable. A /32 is a host route and represents a single IP, typically used for loopback or single-server networks.
- IP ranges don't always collapse to one CIDR block — Arbitrary ranges like 10.0.0.5 to 10.0.0.200 require multiple CIDR blocks to represent exactly. Always verify range alignment before assuming a single block will suffice.
- Smaller prefix lengths mean larger networks — A /8 covers 16.7 million addresses, while a /30 covers only 4. Intuition often works backwards here; remember that the prefix length indicates network bits, not network size.