$netmask-convert 255.255.255.0

Netmask to CIDR Converter

Netmask to CIDR Converter. Enter a Subnet Mask and click Convert to CIDR in this netmask to CIDR converter, or convert a prefix back to a netmask.

Netmask → CIDR

CIDR Result
/24

CIDR → Netmask

/
Netmask Result
255.255.255.0

Additional Details

Wildcard Mask
0.0.0.255
Total Addresses
256
Usable Hosts
254
Binary Mask
11111111.11111111.11111111.00000000

Complete Conversion Reference

CIDRNetmaskWildcardHosts

Enter a subnet mask like 255.255.255.0 or a CIDR prefix like /24 to instantly convert between the two formats. Get bi-directional netmask to CIDR conversion with wildcard mask, total hosts, and network size details — useful for translating between router configurations and IP address documentation.

Every time you configure a router, firewall, or cloud subnet, you run into two ways of writing the same value: the classic dotted-decimal netmask like 255.255.255.0, and the compact CIDR prefix like /24. A netmask to CIDR converter removes the guesswork from switching between them, instantly showing you the usable host count and the network address for whatever value you enter. This guide walks through the binary math behind the conversion, a worked example in both directions, and a quick-reference table of common prefix values so you rarely need to do the arithmetic by hand.

Netmask to CIDR Converter: How the Conversion Works

A netmask and a CIDR value describe the exact same split: how many bits of an IPv4 address are reserved for the network, and how many are left for hosts. Classless Inter-Domain Routing (CIDR) replaced the older class-based system, which fixed that split at 8-bit boundaries only, by letting you set it anywhere. To go from netmask to CIDR, convert each octet to binary and count the total number of 1 bits — that count is your CIDR value. To go the other way, write out that many 1 bits followed by 0s and convert back to dotted-decimal. Applied to a network interface such as a router port or a cloud subnet, the two notations stay interchangeable: 255.255.255.0 is identical to /24, and each marks off a unique segment with its own broadcast address.

  • Write the netmask octets in binary.
  • Count every 1 bit across all four octets.
  • That count is your CIDR value.

The Binary Math Behind Netmask to CIDR

For any IPv4 address, the total address space is 232. Once you know how many bits are reserved for the network — the prefix length — the formula for usable hosts is straightforward:

$$ \text{Usable Hosts} = 2^{(32 - \text{Prefix Length})} - 2 $$

The subtraction of 2 accounts for the network and broadcast addresses, which can't be assigned to a host. A /24 netmask reserves 24 bits for the network, leaving 8 for hosts, so \( 2^{8} - 2 = 254 \) — the same figure an IP subnet calculator would return. A /30, common on point-to-point router links, leaves only 2 host bits, for exactly 2 usable addresses. You can always calculate this by hand, or let a tool determine it for you instantly.

CIDR to Netmask: Converting Back to a Subnet Mask

Going from CIDR to netmask works the same way in reverse. Take the prefix, write that many 1 bits from the left, pad the remainder with 0s to fill 32 bits, then split the result into four 8-bit octets and convert each to decimal. A /20 value becomes 11111111.11111111.11110000.00000000 in binary, which converts to 255.255.240.0. This is also written using dot-decimal notation, and older documentation may still describe it as the network number routing prefix split rather than prefix and host bits — the underlying host identifier math hasn't changed since CIDR was introduced.

Network Prefix and Host Identifier Basics

Every IPv4 address is really two fields glued together: a network prefix that identifies which subnet an address belongs to, and a host identifier that picks out one specific device on it. Routers act as the physical boundary between subnets, forwarding traffic onward only when a destination doesn't match their own prefix — this is what keeps routing tables compact even as the internet has grown to billions of connected devices. Because IP traffic is routed this way rather than by the full 32-bit address, the same principle underlying the TCP/IP suite (Transmission Control Protocol/Internet Protocol), a well-planned split is what gives a network its structure, whether you're subnetting a home network or a global service provider's backbone.

IP Subnet Calculator Reference: Netmask and Host Counts by Prefix

The table below lists the netmask and host count for commonly used prefix values, the same reference an IP subnet calculator draws from internally. Look up your prefix to see the matching netmask and how many hosts it allows.

PrefixNetmaskHosts per Subnet
/8255.0.0.016,777,214
/16255.255.0.065,534
/24255.255.255.0254
/25255.255.255.128126
/28255.255.255.24014
/30255.255.255.2522

Prefix Size and Class-Based Ranges Explained

Before CIDR, the prefix size wasn't something you could choose — it was fixed by IP class: Class A used /8, Class B used /16, and Class C used /24, regardless of how many hosts an organization actually needed. That rigidity wasted enormous blocks of address space, which is exactly the problem CIDR notation was designed to solve: it lets a network administrator hand out a value that matches actual demand, anywhere from a /30 for a two-router link to a /16 or larger for an enterprise network.

Why the Netmask to CIDR Converter Matters for Network Administrators and Cybersecurity Teams

Getting comfortable with this conversion isn't just an academic exercise. Network administrators use it daily when configuring VLANs, firewall rules, and cloud VPC subnets, where providers expect CIDR blocks rather than netmasks. It's also core curriculum for networking certifications, which is why educators and students rely on tools like this one to check subnetting homework instead of working out 32-bit binary math by hand — a basic grasp of IP addressing pays for itself the first time you have to defend a firewall change or write a network security policy.

IP Address Range and Network Address in Practice

Converting a netmask to a CIDR value anchors an IP address range to a specific network address, which is exactly what cloud platforms, VPN configurations, and firewall rules expect when you hand them a block. Getting that boundary right the first time avoids the disruptive fix of re-addressing a live network later.

Routing and Cybersecurity Considerations

On the network side, choosing the right prefix affects routing table size and how quickly a change propagates during a redesign. On the security side, CIDR blocks are exactly what firewall rules, VPN split-tunnel configs, and cybersecurity access-control lists use to scope which addresses may talk to which — get the netmask wrong and you either expose more than intended or lock out an address range someone actually needs. This is part of why IPv6 adopted CIDR-style notation wholesale, keeping netmask-to-prefix conversion relevant even as networks move beyond IPv4.

This tool goes by several names depending on where you learned it — subnet mask calculator, CIDR notation calculator, IP address calculator, subnet mask converter — but the underlying math is identical everywhere. Whether you're going netmask to CIDR or CIDR to netmask, count the bits one direction and expand them the other, and it scales cleanly across subnets of any size.

Related Network Tools

Explore these related tools for subnet calculation and IP address management.

Additional networking calculators for IP address planning and network analysis.

About the author

Subash Geetha Krishnan

Tech Lead for Nimble Storage at HPE Services Storage Support

Subash Geetha Krishnan is a Tech Lead for Nimble Storage at HPE Services Storage Support, based in Singapore, with over 15 years of experience in enterprise storage solutions. He created SubnetCalculate so that accurate networking calculations are free and easy for everyone.

  • Content author: Subash Geetha Krishnan
  • Fact checked by: Subash Geetha Krishnan. Each calculator is built on industry-standard algorithms and tested against known results before it goes live.
  • Published Updated

Comments & Feedback

Share your experience or ask questions about this tool