Subnet Mask Converter

Convert between CIDR notation (/24), decimal mask (255.255.255.0) and binary mask, in either direction.

How it works

Type the value in any of the three formats — /24, 24 (no slash) or 255.255.255.0 — and the tool automatically detects the format and shows the conversion to the other two, plus the wildcard mask (the bitwise complement of the mask, used in Cisco router ACLs) and the total number of addresses in the network.

Relationship between CIDR and decimal mask

The number after the slash in CIDR notation (e.g. /24) indicates how many bits, from left to right, are "1" in the 32-bit binary mask. /24 = 24 bits set to 1 followed by 8 bits set to 0 = 11111111.11111111.11111111.00000000 = 255.255.255.0.

Masks you meet in practice

/8 is 255.0.0.0, /16 is 255.255.0.0 and /24 is 255.255.255.0. For the in-between prefixes, the "broken" octet follows the sequence 128, 192, 224, 240, 248, 252, 254, 255. For instance, /20 is 255.255.240.0: 16 full bits plus 4 bits in the third octet (11110000 = 240).

Block size is 2 to the power of (32 minus the prefix): a /20 holds 4,096 addresses and a /27 holds 32. The wildcard for /20 is 0.0.15.255, which is 255.255.255.255 minus the mask.

When a mask is invalid

Inputs such as 255.0.255.0 or /33 are rejected: the prefix runs from 0 to 32 and the 1 bits cannot be interrupted by a 0. If the value came from older equipment, check that it is not a wildcard typed in place of the mask, such as 0.0.0.255.

Frequently asked questions

What is a wildcard mask?

It's the complement (bitwise inverse) of the subnet mask — mainly used in Cisco router access control lists (ACLs), where the "1" bits indicate which positions can vary.

Does any combination of numbers form a valid mask?

No — a valid subnet mask needs all its "1" bits grouped to the left, with no "0" in between (e.g. 255.255.254.0 is valid, but 255.255.1.0 is not). The tool warns you if the entered mask isn't valid.