Network · Developer

CIDR to subnet mask converter.

Type a prefix length such as /24 to get 255.255.255.0, or paste a subnet mask such as 255.255.255.192 to get /26. Works both ways, and shows the wildcard mask, hex form, binary form, and address counts.

Advertisement

Inputs

Result

Enter a prefix length or a subnet mask.

How a prefix length becomes a subnet mask

A CIDR prefix of /n means the first n bits of the 32-bit address are the network portion. The subnet mask is n one-bits followed by (32 − n) zero-bits, written as four decimal octets. For /24 that is 11111111.11111111.11111111.00000000, or 255.255.255.0. For /26 it is 255.255.255.192, because the last octet holds 2 network bits (11000000 = 192).

Going the other way, count the one-bits in the mask. A valid CIDR mask has all its 1-bits first and all its 0-bits after, so 255.255.255.0 is /24 but 255.0.255.0 is not a valid mask. The most common prefixes: /8 = 255.0.0.0, /16 = 255.255.0.0, /24 = 255.255.255.0, /30 = 255.255.255.252. See the full subnet mask cheat sheet for all 33 values.

Sources (retrieved 2026-10): RFC 4632 (classless inter-domain routing (CIDR)); RFC 3021 (31-bit prefixes on IPv4 point-to-point links).

Frequently asked questions

What is /24 as a subnet mask?

/24 is 255.255.255.0: 24 network bits and 8 host bits, giving 256 addresses and 254 usable hosts.

How do I convert a subnet mask to CIDR?

Convert each octet to binary and count the 1-bits. 255.255.255.192 has 8 + 8 + 8 + 2 = 26 one-bits, so it is /26.

Why is 255.0.255.0 rejected?

CIDR masks must be contiguous: all 1-bits followed by all 0-bits. A mask with a 1-bit after a 0-bit cannot be written as a prefix length.

What is the wildcard mask for a prefix?

It is the bitwise inverse of the subnet mask. For /24 it is 0.0.0.255. Use the wildcard mask calculator for the reverse direction.

Pure arithmetic — no network access

This tool performs standard IPv4 subnet arithmetic entirely in your browser. It does not look anything up, and it doesn't check whether an address or subnet is actually routed, reachable, or assigned to anyone.

Advertisement
Advertisement