Advertisement
Home/Networking Tools/Subnet Mask ↔ CIDR Converter

Subnet Mask ↔ CIDR Converter

Convert an IPv4 subnet mask to CIDR notation or convert a CIDR prefix back to its subnet mask. Also calculate wildcard mask, network bits, host bits and address capacity.

Subnet Mask ↔ CIDR Converter

Convert an IPv4 subnet mask such as 255.255.255.0 to CIDR notation, or convert a CIDR prefix such as /24 back to its subnet mask.

Example: 255.255.255.192

Privacy: this conversion runs entirely in your browser. No subnet mask or CIDR data is uploaded to MK Tech Tools.

Advertisement

What is a subnet mask to CIDR converter?

A subnet mask to CIDR converter translates between the two common ways of describing the network portion of an IPv4 address. A subnet mask is normally written in dotted-decimal format, such as 255.255.255.0, while CIDR notation represents the same information using a prefix such as /24.

These formats are used throughout network configuration, documentation, routing, firewall rules, cloud networks and IP address planning. Being able to quickly convert between a subnet mask and a CIDR prefix can make it easier to understand and configure IPv4 networks.

What is a subnet mask?

A subnet mask is a 32-bit value that identifies which part of an IPv4 address belongs to the network and which part is available for host addresses. It is usually written as four decimal numbers separated by periods.

For example, 255.255.255.0 is a common subnet mask. In binary, it contains 24 consecutive 1 bits followed by 8 zero bits. The 1 bits identify the network portion, while the zero bits identify the host portion.

What is CIDR notation?

CIDR stands for Classless Inter-Domain Routing. CIDR notation uses a slash followed by a prefix length to describe how many bits of an IP address belong to the network.

For example, /24 means that 24 of the 32 IPv4 bits are network bits. It therefore represents the same network boundary as the subnet mask 255.255.255.0.

How does subnet mask to CIDR conversion work?

A valid standard IPv4 subnet mask contains a continuous sequence of binary 1 bits followed by binary 0 bits. To convert the mask to CIDR, the number of leading 1 bits is counted.

For example, 255.255.255.192 is represented in binary with 26 leading 1 bits, so the corresponding CIDR prefix is /26. A /26 subnet leaves 6 bits for addresses within the subnet, providing 64 total IPv4 addresses.

How to use the converter

  1. Select Subnet Mask → CIDR if you have a subnet mask such as 255.255.255.0.
  2. Select CIDR → Subnet Mask if you have a prefix such as /24.
  3. Enter the value in the input field.
  4. Click Convert.
  5. Review the CIDR prefix, subnet mask, wildcard mask, network bits, host bits and address counts.

Subnet mask and CIDR examples

Subnet MaskCIDRHost BitsTotal AddressesTraditional Usable Hosts
255.255.0.0/161665,53665,534
255.255.240.0/20124,0964,094
255.255.255.0/248256254
255.255.255.128/257128126
255.255.255.192/2666462
255.255.255.224/2753230
255.255.255.240/2841614
255.255.255.248/29386
255.255.255.252/30242

Traditional usable-host counts exclude the network and broadcast addresses. /31 and /32 are special cases.

Why must a subnet mask be contiguous?

Standard subnet masks consist of consecutive 1 bits followed by consecutive 0 bits. Once a zero appears in the binary mask, another 1 should not appear later.

For example, 255.255.255.0 is valid, but a pattern with separated network bits would not represent a standard contiguous IPv4 subnet mask. This converter checks for that condition before returning a CIDR prefix.

What is a wildcard mask?

A wildcard mask is the inverse of a subnet mask. Each bit in the subnet mask is reversed: 1 becomes 0 and 0 becomes 1.

For example, the subnet mask 255.255.255.0 produces the wildcard mask 0.0.0.255. Wildcard masks are often encountered in routing and access control configurations.

Frequently asked questions

What CIDR is 255.255.255.0?

255.255.255.0 corresponds to CIDR prefix /24 because the subnet mask contains 24 network bits.

What subnet mask is /24?

The IPv4 subnet mask for /24 is 255.255.255.0.

What CIDR is 255.255.255.192?

255.255.255.192 corresponds to /26. A /26 subnet contains 64 total IPv4 addresses and traditionally provides 62 usable host addresses.

What subnet mask is /28?

A /28 CIDR prefix corresponds to the subnet mask 255.255.255.240. It contains 16 total IPv4 addresses.

Are CIDR and subnet masks the same thing?

They describe the same network boundary using different notation. CIDR uses a prefix such as /24, while the equivalent subnet mask is written as 255.255.255.0.

Can this converter validate a subnet mask?

Yes. The converter checks that the IPv4 subnet mask contains a valid contiguous sequence of network bits before converting it to CIDR.

Advertisement