Routelearn.net
Subnet Tools

CIDR Calculator

Convert between a CIDR prefix length (like /24) and a dotted-decimal subnet mask (like 255.255.255.0). Works in either direction.

How it works

CIDR notation and dotted-decimal subnet masks are two ways to write the same thing: how many bits of an IPv4 address belong to the network. /24 and 255.255.255.0 both mean “the first 24 bits are the network, and the last 8 are the host.”

To convert from a prefix length, just count off that many 1 bits from the left. To convert from a mask, do the reverse: count how many 1 bits it has.

FAQ

What's the difference between this and the Subnet Calculator?
This tool does one specific conversion: prefix length to subnet mask, and back. It also gives you the wildcard mask and address counts that go with it. The Subnet Calculator is different. It takes a full IP address and prefix, then works out the network address, broadcast address, and usable host range for that specific subnet.
How do I convert a subnet mask to a CIDR prefix?
Count the number of 1 bits in the mask's binary form. For example, 255.255.255.0 is 24 ones followed by 8 zeros, so it's /24. Pick "Convert from subnet mask" above and enter the mask, and the tool counts it for you.
Why does entering an invalid mask give an error?
A valid subnet mask must be a single run of 1 bits followed by 0 bits, with no gaps. 255.255.255.0 is valid. 255.0.255.0 is not a real subnet mask, even though it looks like a valid IPv4 number.

Related tools