Subnet Calculator
Advertisement placeholder

Subnet Mask to CIDR Converter

Convert a dotted-decimal subnet mask (e.g. 255.255.255.0) to CIDR prefix length notation.

Subnet Mask

CIDR Prefix

/24

254 usable hosts

11111111.11111111.11111111.00000000

How to Convert Subnet Mask to CIDR

To convert a subnet mask to CIDR notation, convert each octet to binary and count the number of consecutive 1-bits from the left. For example:

  • 255.255.255.011111111.11111111.11111111.00000000 → 24 ones → /24
  • 255.255.240.011111111.11111111.11110000.00000000 → 20 ones → /20

Valid Subnet Masks

A valid subnet mask must have all 1-bits contiguous from the left, followed by all 0-bits. For example, 255.255.128.0 is valid (/17), but 255.255.128.1 is not, because it has a 0-bit followed by a 1-bit.

Why CIDR Notation Matters

CIDR replaced the old classful networking system. Instead of being limited to Class A (/8), Class B (/16), and Class C (/24) networks, CIDR allows any prefix length from /0 to /32. This means you can allocate exactly the number of addresses you need, reducing IP address waste.