Subnet Mask to CIDR Converter — 255.255.255.0 Becomes /24
Convert dotted netmask (e.g. 255.255.248.0) into /prefix, binary & wildcard.
| Input | Prefix | Wildcard | Hosts per subnet |
|---|---|---|---|
255.255.255.0 | /24 | 0.0.0.255 | 254 |
255.255.248.0 | /21 | 0.0.7.255 | 2,046 |
255.255.255.252 | /30 | 0.0.0.3 | 2 |
255.0.0.0 | /8 | 0.255.255.255 | 16,777,214 |
255.255.0.255 | ✗ the 1 bits are not contiguous — not a subnet mask | ||
- Invalid lines are left out of the result.
When to use the Dotted-Decimal Subnet Mask to /CIDR Prefix Converter
Prefix, wildcard and hosts
Every mask becomes a prefix length, an ACL wildcard mask and the hosts per subnet, handy when moving old configs to devices that use CIDR notation. For example 255.255.255.192 becomes /26 with wildcard 0.0.0.63 and 62 hosts per subnet.
Invalid masks refused
A mask must be a run of 1 bits followed by 0 bits. Values such as 255.255.0.255 are refused with an explanation, because they cannot work as a subnet mask.
Lists from old configs
Paste a mask column from router exports, DHCP or inventory spreadsheets and convert them all at once. Put each mask on its own line; lines starting with a hash are treated as comments and skipped.
Tested against Python
The prefix length of every valid mask is compared with Python's ipaddress module, edge cases /0, /31 and /32 included.
Frequently asked questions
How do I get the prefix from a mask?
Count the 1 bits. For example 255.255.248.0 holds 8 + 8 + 5 one bits, so its prefix is /21.
Which masks are common?
255.255.255.0 (/24) for LANs, 255.255.255.252 (/30) for older router links and 255.255.255.254 (/31) for modern point-to-point links.
What about the reverse?
Use the CIDR to Subnet Mask converter to turn /24 into 255.255.255.0.
Does IPv6 use subnet masks?
No; IPv6 only uses prefix lengths such as /64. The standard IPv6 LAN subnet is /64, because SLAAC needs a 64-bit interface ID.
Is my data sent to a server?
No. Everything is computed in your browser, so the device configs you paste are not sent anywhere.
Similar tools
- /CIDR Prefix to Subnet & Wildcard Mask ConverterConvert /1 through /32 CIDR prefix length into netmask, wildcard & usable hosts.
- CIDR Exclusion & WireGuard AllowedIPs BuilderSubtract LAN or private ranges from 0.0.0.0/0 or any block and get the minimal CIDR list for WireGuard, routing or MikroTik.
- CIDR & IP Range to Full Address List ExpanderExpand IPv4/IPv6 CIDRs and start–end ranges into every individual address, ready to export as TXT for scanners and ACLs.
- IP / CIDR List Diff & Allowlist AuditorCompare two IP/CIDR lists by real address coverage: what was added, removed, or overlaps — ideal for firewall allowlist reviews.