Subnet Mask Calculator
Convert a prefix length to a subnet mask, or a mask to its prefix, with a full reference table.
Jump to toolWhat Is a Subnet Mask?
A subnet mask marks which part of an IPv4 address identifies the network and which part identifies the device. Written like an address, such as 255.255.255.0, it is equivalent to a prefix length: 255.255.255.0 is /24, meaning the first 24 bits identify the network.
This tool converts in both directions, from a prefix length to its dotted subnet mask and from a mask back to its prefix length.
How to Convert a Prefix to a Subnet Mask
- Enter an IP address, then either a CIDR prefix or a subnet mask.
- Select Calculate.
- Read the matching mask or prefix and the network it describes.
Subnet Mask Cheat Sheet
| Prefix | Subnet mask, addresses and usable hosts |
|---|---|
| /16 | 255.255.0.0: 65,536 addresses, 65,534 usable |
| /17 | 255.255.128.0: 32,768 addresses, 32,766 usable |
| /18 | 255.255.192.0: 16,384 addresses, 16,382 usable |
| /19 | 255.255.224.0: 8,192 addresses, 8,190 usable |
| /20 | 255.255.240.0: 4,096 addresses, 4,094 usable |
| /21 | 255.255.248.0: 2,048 addresses, 2,046 usable |
| /22 | 255.255.252.0: 1,024 addresses, 1,022 usable |
| /23 | 255.255.254.0: 512 addresses, 510 usable |
| /24 | 255.255.255.0: 256 addresses, 254 usable |
| /25 | 255.255.255.128: 128 addresses, 126 usable |
| /26 | 255.255.255.192: 64 addresses, 62 usable |
| /27 | 255.255.255.224: 32 addresses, 30 usable |
| /28 | 255.255.255.240: 16 addresses, 14 usable |
| /29 | 255.255.255.248: 8 addresses, 6 usable |
| /30 | 255.255.255.252: 4 addresses, 2 usable |
| /31 | 255.255.255.254: 2 addresses, 2 usable (point-to-point links) |
| /32 | 255.255.255.255: 1 addresses, 1 usable (one host) |
How a Mask Relates to a Prefix
Write the mask in binary and count the 1s: 255.255.255.0 is twenty-four 1s followed by eight 0s, so it is /24. Valid masks always have all their 1s first, which is why values such as 255.255.0.255 are not allowed.
Subnet Mask Calculator FAQ
Need the inverse mask for an ACL?
Convert a subnet mask to a wildcard mask.
Related Tools
Tools that often come next after this one