About the CIDR to Subnet Mask
This calculator converts a CIDR prefix length, the slash notation used in network configuration like /24, into its equivalent dotted-decimal subnet mask, wildcard mask, and host counts. It is aimed at network administrators and students who need to translate between CIDR notation and the older subnet mask format quickly.
How It Works
Enter a prefix length from 0 to 32. The calculator builds a 32-bit mask by setting that many leading bits to 1 and the rest to 0, then splits the result into four 8-bit octets to display as a standard subnet mask. It also computes the wildcard mask (the inverse of each octet), the total address count, and the number of usable host addresses.
Formula & Methodology
The prefix is first clamped to the 0-32 range and rounded to a whole number. A 32-character binary string is built by repeating "1" prefix times and padding the rest with "0", then that string is sliced into four 8-bit chunks and each is parsed as a decimal octet. The wildcard mask subtracts each octet from 255. Total addresses come from raising 2 to the power of the remaining host bits (32 minus the prefix), and usable hosts subtracts the 2 addresses reserved for the network and broadcast identifiers, except for /31 (point-to-point links) and /32 (single host), which the calculator sets to 0 usable hosts per standard networking convention.
Examples
A /24 home or office network
Entering a prefix of 24 returns the subnet mask 255.255.255.0, wildcard mask 0.0.0.255, 256 total addresses, and 254 usable hosts after subtracting the network and broadcast addresses.
A /28 subdivided subnet
Entering a prefix of 28 returns the subnet mask 255.255.255.240, 16 total addresses, and 14 usable hosts, a common size for small isolated network segments.
Advantages
- Converts CIDR slash notation to dotted-decimal subnet mask format instantly, without manual binary math.
- Shows total addresses and usable hosts side by side, making subnet sizing decisions easier.
- Applies the correct special-case host counts for /31 and /32, which trip up manual calculations.
Common Mistakes
- Forgetting to subtract 2 for the network and broadcast addresses when estimating how many devices a subnet can hold.
- Assuming /31 and /32 subnets follow the same usable-host formula as larger subnets, when they use different point-to-point and host-route conventions.
- Mixing up the subnet mask and the wildcard mask, which are inverses of each other and used in different contexts (subnetting versus access control list configuration).
Edge Cases to Watch For
- Prefix values outside 0-32 are clamped to that range, so entering 40 is treated the same as entering 32.
- Non-integer prefix values are rounded to the nearest whole number before the mask is built.
- /31 and /32 return 0 usable hosts, following the special conventions where /31 is used for point-to-point links and /32 identifies a single host route rather than a subnet with network/broadcast addresses.
Common Use Cases
- Network administrators configuring routers or firewalls that require a dotted-decimal subnet mask instead of CIDR notation.
- Students studying for networking certifications who need to practice converting between CIDR and subnet mask formats.
- IT staff planning how to subdivide an IP address range and verifying how many hosts each subnet size will support.