Subnet Mask CIDR Calculator

A CIDR prefix length is the compact way to describe an IPv4 subnet, but day to day you often need the dotted-decimal mask, the address count, and the usable host count. Enter a prefix length from 0 to 32 and this calculator returns the subnet mask, the wildcard (inverse) mask, the total number of addresses in the block, and the number of usable host addresses. It implements the standard CIDR rules defined in RFC 4632.

-
-
0.00
0.00

CIDR conversion logic

total addresses = 2^(32 - prefix)
usable hosts = total addresses - 2 (for prefix 0 to 30)
mask = first (prefix) bits set to 1, rest 0, split into 4 octets
wildcard = 255 minus each mask octet

For a /31 the two addresses form a point-to-point link (RFC 3021), and a /32 is a single host, so the minus-2 rule does not apply to those prefixes.

Common prefixes

  • /8: mask 255.0.0.0, 16,777,216 addresses.
  • /16: mask 255.255.0.0, 65,536 addresses.
  • /24: mask 255.255.255.0, 256 addresses, 254 usable hosts.
  • /26: mask 255.255.255.192, 64 addresses, 62 usable hosts.
  • /30: mask 255.255.255.252, 4 addresses, 2 usable hosts.

Subnet mask: frequently asked questions

What does a CIDR prefix mean?

A CIDR prefix such as /24 is the number of leading bits in the IPv4 address that identify the network. The remaining bits identify hosts. A /24 uses 24 network bits, leaving 8 host bits, which is 256 total addresses. CIDR replaced the old fixed class A, B, C scheme described in RFC 4632.

How do I get the subnet mask from a prefix?

Set the leftmost prefix bits to 1 and the rest to 0, then split the 32-bit value into four 8-bit octets in decimal. A /24 is 11111111.11111111.11111111.00000000, which is 255.255.255.0. A /26 is 255.255.255.192.

Why are usable hosts two fewer than total addresses?

In a standard IPv4 subnet, the first address is the network identifier and the last is the broadcast address, neither of which is assigned to a host. So usable hosts equal total addresses minus 2. A /24 has 256 total addresses and 254 usable hosts. For /31 and /32 the usual host subtraction does not apply.

What is the wildcard mask?

The wildcard mask is the bitwise inverse of the subnet mask, used by access control lists in some router platforms. For a /24, the subnet mask 255.255.255.0 has the wildcard mask 0.0.0.255.

Official sources

Reviewed by the CalculatorHub team, edited by James Graham, 19 June 2026. See our methodology.