Subnet Mask to CIDR Converter
Find prefix length from contiguous masks.
Subnet Mask to CIDR Converter: inputs and results
Enter an IP address, CIDR prefix, or range. Then check its first and last address below.
Calculated Boundaries & ParametersReady
Key Capabilities
- •100% Client-Side: Zero telemetry or server latency.
- •RFC Compliant: Exact 32-bit and 128-bit integer precision.
- •Quick Copy: Instant access to CIDR, mask, and range bounds.
- •Cross-Platform: Works on desktop, tablet, and mobile browsers.
Related Masks, Wildcards & ACLAll Tools
IP Address and Mask Calculator
Calculate the corresponding network range.
CIDR to Subnet Mask Converter
Convert IPv4 prefixes to dotted masks.
Subnet Mask Validator
Check mask structure and contiguity.
Subnet Mask to Wildcard Converter
Calculate the inverse IPv4 mask.
Wildcard Mask to Subnet Mask Converter
Convert compatible contiguous wildcard masks.
ACL Wildcard Match Calculator
Evaluate address-and-wildcard matching.
How Subnet Mask to CIDR Converter Works?
This tool works by confirming that the mask is contiguous and then counting its 1 bits. The count is the CIDR prefix length.
Enter a dotted mask
Type a mask such as
255.255.252.0.Check each octet value
Every octet must be one of 9 values: 0, 128, 192, 224, 240, 248, 252, 254, or 255.
Check contiguity
An octet below 255 must be followed only by 0 octets.
Count the 1 bits
255 (8) + 255 (8) + 252 (6) + 0 (0) = 22 →
/22.
Subnet Mask to CIDR Converter Formula
The formula is p = 32 − log2(2^32 − Mask), which equals the number of 1 bits in a contiguous mask.
Bit count
p = Σ popcount(octet)Counts the 1 bits.
Integer form
p = 32 − log2(2^32 − M)M is the mask as an integer.
Octet lookup
128→1, 192→2, 224→3, 240→4, 248→5, 252→6, 254→7, 255→8Bits contributed by each octet value.
Worked example: 255.255.252.0
255 → 8 bits 255 → 8 bits 252 → 11111100 → 6 bits 0 → 0 bits CIDR = /22
Subnet Mask to CIDR Converter Conversion Table
The table maps 16 dotted masks, where the 3rd or 4th octet holds each of the 8 partial values, to their CIDR prefix.
| Subnet Mask | Partial Octet | Partial Octet Binary | CIDR |
|---|---|---|---|
| 255.255.128.0 | 128 | 10000000 | /17 |
| 255.255.192.0 | 192 | 11000000 | /18 |
| 255.255.224.0 | 224 | 11100000 | /19 |
| 255.255.240.0 | 240 | 11110000 | /20 |
| 255.255.248.0 | 248 | 11111000 | /21 |
| 255.255.252.0 | 252 | 11111100 | /22 |
| 255.255.254.0 | 254 | 11111110 | /23 |
| 255.255.255.0 | 255 | 11111111 | /24 |
| 255.255.255.128 | 128 | 10000000 | /25 |
| 255.255.255.192 | 192 | 11000000 | /26 |
| 255.255.255.224 | 224 | 11100000 | /27 |
| 255.255.255.240 | 240 | 11110000 | /28 |
| 255.255.255.248 | 248 | 11111000 | /29 |
| 255.255.255.252 | 252 | 11111100 | /30 |
| 255.255.255.254 | 254 | 11111110 | /31 |
| 255.255.255.255 | 255 | 11111111 | /32 |
What is Subnet Mask to CIDR Converter?
The Subnet Mask to CIDR Converter is a tool that turns a dotted-decimal IPv4 subnet mask into its CIDR prefix length. 255.255.252.0 becomes /22.
Prefix notation is shorter and fits directly after an address, as in 10.0.0.0/22. Cloud platforms, Linux ip commands, and routing tables use it everywhere. The converter turns masks copied from older devices into that format.
The converter accepts contiguous masks only. Non-contiguous masks such as 255.255.0.255 have no CIDR equivalent, and the converter flags them as invalid.
What are the uses of Subnet Mask to CIDR Converter?
There are 4 main uses of the Subnet Mask to CIDR Converter, including migrations, cloud entries, and log analysis.
Migrating firewall objects
Objects stored with dotted masks become CIDR entries on the new platform.
Entering cloud network ranges
AWS, Azure, and Google Cloud consoles accept CIDR only.
Reading Linux route tables
Comparing
route -nmask output withip routeCIDR output requires conversion.Shortening documentation
Design tables use
/22instead of255.255.252.0to save space.