What is a subnet mask to CIDR converter?
A subnet mask to CIDR converter translates between the two common ways of describing the network portion of an IPv4 address. A subnet mask is normally written in dotted-decimal format, such as 255.255.255.0, while CIDR notation represents the same information using a prefix such as /24.
These formats are used throughout network configuration, documentation, routing, firewall rules, cloud networks and IP address planning. Being able to quickly convert between a subnet mask and a CIDR prefix can make it easier to understand and configure IPv4 networks.
What is a subnet mask?
A subnet mask is a 32-bit value that identifies which part of an IPv4 address belongs to the network and which part is available for host addresses. It is usually written as four decimal numbers separated by periods.
For example, 255.255.255.0 is a common subnet mask. In binary, it contains 24 consecutive 1 bits followed by 8 zero bits. The 1 bits identify the network portion, while the zero bits identify the host portion.
What is CIDR notation?
CIDR stands for Classless Inter-Domain Routing. CIDR notation uses a slash followed by a prefix length to describe how many bits of an IP address belong to the network.
For example, /24 means that 24 of the 32 IPv4 bits are network bits. It therefore represents the same network boundary as the subnet mask 255.255.255.0.
How does subnet mask to CIDR conversion work?
A valid standard IPv4 subnet mask contains a continuous sequence of binary 1 bits followed by binary 0 bits. To convert the mask to CIDR, the number of leading 1 bits is counted.
For example, 255.255.255.192 is represented in binary with 26 leading 1 bits, so the corresponding CIDR prefix is /26. A /26 subnet leaves 6 bits for addresses within the subnet, providing 64 total IPv4 addresses.
How to use the converter
- Select Subnet Mask → CIDR if you have a subnet mask such as 255.255.255.0.
- Select CIDR → Subnet Mask if you have a prefix such as /24.
- Enter the value in the input field.
- Click Convert.
- Review the CIDR prefix, subnet mask, wildcard mask, network bits, host bits and address counts.
Subnet mask and CIDR examples
| Subnet Mask | CIDR | Host Bits | Total Addresses | Traditional Usable Hosts |
|---|---|---|---|---|
| 255.255.0.0 | /16 | 16 | 65,536 | 65,534 |
| 255.255.240.0 | /20 | 12 | 4,096 | 4,094 |
| 255.255.255.0 | /24 | 8 | 256 | 254 |
| 255.255.255.128 | /25 | 7 | 128 | 126 |
| 255.255.255.192 | /26 | 6 | 64 | 62 |
| 255.255.255.224 | /27 | 5 | 32 | 30 |
| 255.255.255.240 | /28 | 4 | 16 | 14 |
| 255.255.255.248 | /29 | 3 | 8 | 6 |
| 255.255.255.252 | /30 | 2 | 4 | 2 |
Traditional usable-host counts exclude the network and broadcast addresses. /31 and /32 are special cases.
Why must a subnet mask be contiguous?
Standard subnet masks consist of consecutive 1 bits followed by consecutive 0 bits. Once a zero appears in the binary mask, another 1 should not appear later.
For example, 255.255.255.0 is valid, but a pattern with separated network bits would not represent a standard contiguous IPv4 subnet mask. This converter checks for that condition before returning a CIDR prefix.
What is a wildcard mask?
A wildcard mask is the inverse of a subnet mask. Each bit in the subnet mask is reversed: 1 becomes 0 and 0 becomes 1.
For example, the subnet mask 255.255.255.0 produces the wildcard mask 0.0.0.255. Wildcard masks are often encountered in routing and access control configurations.
Frequently asked questions
What CIDR is 255.255.255.0?
255.255.255.0 corresponds to CIDR prefix /24 because the subnet mask contains 24 network bits.
What subnet mask is /24?
The IPv4 subnet mask for /24 is 255.255.255.0.
What CIDR is 255.255.255.192?
255.255.255.192 corresponds to /26. A /26 subnet contains 64 total IPv4 addresses and traditionally provides 62 usable host addresses.
What subnet mask is /28?
A /28 CIDR prefix corresponds to the subnet mask 255.255.255.240. It contains 16 total IPv4 addresses.
Are CIDR and subnet masks the same thing?
They describe the same network boundary using different notation. CIDR uses a prefix such as /24, while the equivalent subnet mask is written as 255.255.255.0.
Can this converter validate a subnet mask?
Yes. The converter checks that the IPv4 subnet mask contains a valid contiguous sequence of network bits before converting it to CIDR.