IPv4 mask notation

Subnet Mask / CIDR Converter

Convert an IPv4 netmask (subnet mask), CIDR prefix, or wildcard mask into the other formats. Binary masks and address counts update entirely in your browser.

Mask formats

Enter a CIDR prefix or mask

Choose the format you already have. Every equivalent updates locally.

Example: /24

Calculated locally. The entered value is not sent anywhere.

Equivalent formats

/24 subnet

Usable hosts follow modern /31 point-to-point and /32 host-route rules.

CIDR prefix
/24
Subnet mask
255.255.255.0
Wildcard mask
0.0.0.255
Binary mask
11111111.11111111.11111111.00000000
Total addresses
256
Usable hosts
254
Prefix = network bits32 − prefix = host bits2host bits = addresses

From netmask to prefix

Convert 255.255.254.0 to CIDR

Select Subnet mask as the input format and enter 255.255.254.0. The result is /23, with wildcard mask 0.0.1.255, 512 total addresses, and normally 510 usable hosts.

The slash number counts network bits, not addresses, as described in RFC 4632. To apply a prefix to an actual address, use the CIDR to IP range calculator.

Quick example

Convert /24 to 255.255.255.0

A /24 prefix reserves 24 bits for the network and leaves 8 bits for addresses. Its subnet mask is 255.255.255.0, its wildcard mask is 0.0.0.255, and it contains 256 total addresses with 254 normally usable by hosts.

Common conversions

CIDR, subnet mask, and wildcard mask table

Use this table as a quick reference for frequently used IPv4 prefixes. Address counts include the entire block.

Common CIDR prefixes with equivalent subnet and wildcard masks and total addresses
CIDRSubnet maskWildcard maskAddresses
/8255.0.0.00.255.255.25516,777,216
/16255.255.0.00.0.255.25565,536
/20255.255.240.00.0.15.2554,096
/21255.255.248.00.0.7.2552,048
/22255.255.252.00.0.3.2551,024
/23255.255.254.00.0.1.255512
/24255.255.255.00.0.0.255256
/25255.255.255.1280.0.0.127128
/26255.255.255.1920.0.0.6364
/27255.255.255.2240.0.0.3132
/28255.255.255.2400.0.0.1516
/29255.255.255.2480.0.0.78
/30255.255.255.2520.0.0.34
/31255.255.255.2540.0.0.12
/32255.255.255.2550.0.0.01

Reading masks

How the three formats relate

CIDR prefix

The number after the slash is the count of network bits. A larger prefix leaves fewer host bits and creates a smaller address block.

Subnet mask

Also called a netmask. Network bits appear as consecutive ones and host bits as consecutive zeroes. In dotted decimal, each group of eight bits becomes one octet.

Wildcard mask

A wildcard mask is the inverse of the subnet mask: every one becomes zero and every zero becomes one. Network access-control rules commonly use it.

Address count

Raise 2 to the number of host bits. Traditional subnets reserve the network and broadcast addresses, while /31 and /32 have special uses.

Validation

Subnet mask bits must be contiguous

A valid CIDR mask has one uninterrupted run of 1 network bits followed by 0 host bits. For example, 255.255.255.0 is valid, but 255.0.255.0 is not. This converter rejects masks that cannot be represented by a single CIDR prefix.

Some ACL systems permit noncontiguous wildcard masks, as Cisco's access-list documentation explains. Those are outside this single-prefix converter's scope; rejection here does not mean every ACL wildcard must be contiguous.

For usable address ranges, use the IPv4 subnet calculator. Its host counts include the special /31 point-to-point and /32 host-route cases; a provider may reserve additional addresses.

Common questions

Subnet mask and CIDR conversion FAQ

Is a netmask the same as a subnet mask?

For an IPv4 network, netmask and subnet mask refer to the same mask. Both distinguish the network bits from the host bits. A wildcard mask uses the opposite bit values.

How do I convert a subnet mask to CIDR notation?

Write the mask in binary and count its contiguous one bits. For example, 255.255.254.0 has 8 + 8 + 7 = 23 network bits, so its prefix is /23.

How do I calculate a wildcard mask?

Subtract each subnet-mask octet from 255. For 255.255.254.0, the wildcard is 0.0.1.255. This converter supports wildcard masks that describe one CIDR block.

Why does this converter reject a noncontiguous wildcard?

Some access-control lists support noncontiguous wildcard masks, but those masks do not describe one CIDR block. This converter only accepts wildcards whose inverse is a contiguous subnet mask.

Can a subnet mask tell me my IP range?

Not by itself. The mask gives the network size, but you also need an IP address in that network to find its first and last addresses.