Security

Subnet Mask to CIDR Converter

Convert an IPv4 subnet mask into its CIDR prefix length.

Last reviewed: April 30, 2026Free toolMethodology

Subnet Mask to CIDR Converter

These fields start with sample inputs. Keep them or replace them, then run the tool to show a fresh result.

Result

Calculating the sample result.

Why it matters

Subnet masks still show up in legacy docs and infrastructure tickets, while modern tooling usually expects CIDR notation.

When to use

  • Translating old network documentation
  • Preparing firewall or subnet entries in CIDR form
  • Sanity-checking an IPv4 mask quickly

Inputs & Outputs

Inputs

  • Subnet mask should be entered in dotted decimal IPv4 form, such as 255.255.255.0.

Outputs

  • CIDR prefix shows the slash notation equivalent.
  • Binary mask view helps visualize the network bits behind the conversion.

Mask conversion method

The tool converts the dotted-decimal mask into binary and counts the consecutive leading 1 bits to determine the CIDR prefix length.

CIDR prefix = count of leading 1 bits in the subnet mask

Worked example

1

Legacy network doc translation

An engineer wants to convert 255.255.254.0 into slash notation.

Inputs

  • Subnet mask: 255.255.254.0

Steps

  • Convert the mask to binary
  • Count the leading 1 bits

Result

  • The tool returns the corresponding CIDR prefix length.

Edge cases & caveats

  • Only contiguous masks represent valid CIDR prefixes.
  • Malformed or non-contiguous masks will not map cleanly to a standard prefix.

Frequently Asked Questions

Why does 255.255.255.0 equal /24?

Because the mask contains 24 leading 1 bits followed by 8 zero bits.

Can every dotted mask be converted to CIDR?

Only valid contiguous subnet masks map cleanly to standard CIDR notation.

Keep going