What is a CIDR to Subnet Mask Calculator?
Classless Inter-Domain Routing (CIDR) notation describes a network using a prefix length such as /24. This calculator converts that prefix length into the equivalent dotted-decimal subnet mask (e.g. 255.255.255.0), along with the wildcard mask, total address count, and number of usable hosts. It works for any prefix from /0 to /32 and applies to IPv4 networks worldwide.
How to use it
Enter the CIDR prefix length — the number after the slash — and the calculator returns the matching subnet mask and related figures. For example, type 24 to see the mask for a typical home or small-office network.
The formula explained
A subnet mask is a 32-bit number whose leading n bits are set to 1 and the rest to 0. We build it by taking the all-ones value \(2^{32} - 1\) and shifting it left by \(32 - n\) positions. Splitting the 32 bits into four 8-bit groups gives the four octets. Each octet equals \(256 - 2^{8 - \text{bits}}\) where bits is how many of that octet's bits fall inside the prefix.
$$\text{Subnet Mask} = \left(2^{32} - 2^{\,32 - \text{Prefix (/n)}}\right) \;\text{in dotted decimal}$$
Worked example
For /26: the mask has 26 leading ones. The first three octets are fully covered (255.255.255), and the fourth octet has 2 bits: $$256 - 2^{8-2} = 256 - 64 = 192$$ So the mask is 255.255.255.192. Total addresses = \(2^{32-26} = 64\), and usable hosts = \(64 - 2 = 62\).
FAQ
Why subtract 2 for usable hosts? One address is the network identifier and one is the broadcast address, leaving the rest for hosts. (For /31 and /32 special point-to-point rules apply.)
What is a wildcard mask? It is the bitwise inverse of the subnet mask (255 minus each octet), commonly used in ACLs and routing protocols like OSPF.
Does this work for IPv6? No — IPv6 uses 128-bit addresses and rarely uses dotted-decimal masks; this tool covers IPv4 only.