Skip to content
ENExplore Calculators

Network Prefix Calculator

Convert between subnet masks and CIDR prefix lengths in either direction.

About Network Prefix Calculator

A subnet mask's CIDR prefix length equals the count of consecutive 1-bits starting from the most significant bit. Counting the 1-bits in a valid mask (e.g. 255.255.255.0 = 11111111.11111111.11111111.00000000 → 24 ones) gives the prefix directly, since a legitimate subnet mask always has all its 1-bits contiguous at the start.

Formula

Prefix from mask

prefix = count of leading 1-bits in the mask

mask
The subnet mask in binary

Worked example

With the default values below, Network Prefix Calculator returns CIDR Prefix of /24. Change any input above and every figure here is recalculated in your browser.

Inputs used

Subnet Mask
255.255.255.0

Results

CIDR Prefix
/24
Total Addresses
256
Usable Hosts
254
Binary Mask
11111111.11111111.11111111.00000000

Step by step

  1. 1Values used
  2. 2Prefix from mask
  3. 3CIDR Prefix= /24
  4. 4Total Addresses= 256
  5. 5Usable Hosts= 254
  6. 6Binary Mask= 11111111.11111111.11111111.00000000

Assumptions and limits

  • The result is derived only from the single input listed above. Anything not among them is not part of the calculation.
  • In particular, this calculator does not take inflation, tax, fees or charges or compounding frequency into account.
  • Figures are rounded for display to whole numbers, so totals built from several rounded parts can differ slightly from the unrounded arithmetic.

How these calculators are built and tested is described on the Methodology page. If a figure looks wrong, please report it.

Frequently Asked Questions

What CIDR prefix is 255.255.255.0?

255.255.255.0 has 24 leading 1-bits, so it is a /24.

What if my mask bits aren't contiguous?

A standard subnet mask must have all its 1-bits together at the start, followed by all 0-bits. If they're not contiguous, the value isn't a valid subnet mask and has no direct CIDR equivalent — it may be a wildcard mask instead.

How is this different from the wildcard mask calculator?

This tool converts a subnet mask to its CIDR prefix length. The wildcard mask calculator instead inverts a subnet mask to produce the wildcard (ACL/OSPF) form — a different, complementary conversion.

Network Prefix Calculator | Calcrivo