Network Prefix Calculator
Enter a dotted-decimal subnet mask to find its CIDR prefix length.
Inputs
Dotted-decimal subnet mask, e.g. 255.255.255.192
CIDR Prefix
/24
Total Addresses
256
Usable Hosts
254
Binary Mask
11111111.11111111.11111111.00000000
Step by step
Values used
Subnet Mask = 255.255.255.0
Prefix from mask
prefix = count of leading 1-bits in the mask
CIDR Prefix
= /24
Total Addresses
= 256
Usable Hosts
= 254
Binary Mask
= 11111111.11111111.11111111.00000000
How it works
A subnet mask's CIDR prefix length equals the count of consecutive 1-bits starting from the most significant bit. Counting the 1-bits in a valid mask (e.g. 255.255.255.0 = 11111111.11111111.11111111.00000000 → 24 ones) gives the prefix directly, since a legitimate subnet mask always has all its 1-bits contiguous at the start.
Formula
Prefix from mask
prefix = count of leading 1-bits in the mask
- mask
- The subnet mask in binary
Frequently Asked Questions
What CIDR prefix is 255.255.255.0?
255.255.255.0 has 24 leading 1-bits, so it is a /24.
What if my mask bits aren't contiguous?
A standard subnet mask must have all its 1-bits together at the start, followed by all 0-bits. If they're not contiguous, the value isn't a valid subnet mask and has no direct CIDR equivalent — it may be a wildcard mask instead.
How is this different from the wildcard mask calculator?
This tool converts a subnet mask to its CIDR prefix length. The wildcard mask calculator instead inverts a subnet mask to produce the wildcard (ACL/OSPF) form — a different, complementary conversion.