Subnet mask calculator
Convert between subnet mask, CIDR prefix, wildcard mask and host count.
Runs 100% in your browserHow to convert subnet masks
- Enter a mask or CIDR. Type a subnet mask in dotted form or a CIDR like /24.
- Read the conversions. Mask, CIDR prefix, wildcard, host count and binary appear instantly.
Two ways of writing the same boundary
A subnet mask and a CIDR prefix describe the identical thing — where an address stops being "network"
and starts being "host" — in two different notations. The mask spells it out octet by octet
(255.255.255.0), while the prefix just counts the leading 1-bits (/24).
Network gear and cloud consoles are maddeningly inconsistent about which one a given field wants, so
converting between them on the fly is one of the most common reasons engineers reach for a calculator.
Type either form here and the page fills in the other, along with the wildcard, host count and binary
view, so you can paste whatever the box in front of you expects.
Why a mask must be contiguous
A legal IPv4 mask is always a solid run of 1-bits followed by a solid run of 0-bits — never a mix.
That is what makes 255.255.255.0 valid (twenty-four 1s, then eight 0s) and
255.255.0.255 illegal: its bits go 1s, then 0s, then 1s again, which no prefix length can
represent. The reason is structural — the network portion has to be the leading bits so a
router can compare addresses with a single bit-shift, so the 1s can only sit on the left. This tool
rejects non-contiguous masks rather than silently accepting them, which catches typos like a
transposed octet before they reach a device that would also reject them.
Wildcard masks and the off-by-one octets
The wildcard mask is the bitwise inverse of the subnet mask — a /24 has the wildcard
0.0.0.255 — and it is what Cisco access lists and OSPF expect, where a 1 bit
means "ignore this position when matching". It is easy to mistype because it is not simply the
mask with octets swapped; each bit flips. Watch the boundary octets too: a /26 mask is
255.255.255.192, not a clean 255 or 0, because the split falls
mid-octet (192 is 11000000). Seeing the binary alongside makes those non-obvious values
obvious. Everything is computed in your browser. To expand a full block into its address range, use the
CIDR calculator.
Frequently asked questions
- A 32-bit value that marks which bits of an IPv4 address are the network portion (1s) and which are the host portion (0s). 255.255.255.0 means "first 24 bits are the network."
- The prefix /N is just the number of 1-bits in the mask. /24 ↔ 255.255.255.0, /25 ↔ 255.255.255.128, /30 ↔ 255.255.255.252, etc.
- The bitwise inverse of the subnet mask. /24 has a wildcard 0.0.0.255. Used in Cisco ACLs and OSPF.
- Yes — type any valid mask like 255.255.240.0 and the page reports its prefix length, host count and wildcard.