Free network utility
CIDR and Subnet Mask Converter
Convert IPv4 CIDR prefix lengths to subnet masks, wildcard masks, and address capacity.
Convert a prefix, subnet mask, or wildcard mask
Choose the representation you already have, then enter only that value. Prefix mode accepts /0 through /32. Subnet-mask mode accepts a contiguous dotted IPv4 mask such as 255.255.255.192. Wildcard mode accepts the exact bitwise inverse, such as 0.0.0.63. RouterNAT returns all three forms, a 32-bit binary mask, network and host-bit counts, total address capacity, conventional usable-host capacity, and the block increment. It also builds a complete /0 through /32 reference table. Conversion runs in the browser and does not submit the value to the application server. This page converts representations; it does not need or request an IP address, router login, or live network configuration.
CIDR prefix length describes a bit boundary
IPv4 contains 32 bits. A CIDR prefix states how many consecutive leading bits identify the network portion. A /24 therefore has 24 network bits and 8 host bits. The slash is notation, not division. When an address is included, 192.168.10.37/24 means the address is interpreted using a 24-bit network prefix; the prefix alone does not reveal the network address because no address bits were supplied. The converter accepts the prefix by itself because its purpose is representation and capacity. Use a subnet calculator when an actual IPv4 address must be combined with the mask to find the containing network, broadcast boundary, and host range.
A subnet mask writes the same boundary in dotted decimal
A conventional IPv4 subnet mask contains network bits set to one followed by host bits set to zero. The 32 bits are separated into four 8-bit octets and each octet is written in decimal. For /24 the binary mask is 11111111.11111111.11111111.00000000, which becomes 255.255.255.0. For /26, the final octet begins with two one bits: 11000000 equals 192, so the mask is 255.255.255.192. CIDR and a contiguous subnet mask carry the same boundary information. They do not assign an address, create a VLAN, configure DHCP, or prove that a proposed network is available.
Why subnet-mask bits must be contiguous
Modern CIDR prefixes describe one uninterrupted run of leading network bits. A mask such as 255.255.0.255 has one bits after zero bits and cannot be represented by a single prefix length. Quietly counting the one bits would produce a dangerously incorrect conversion because /24 implies a different boundary. RouterNAT rejects masks with holes instead of rounding or guessing. A contiguous dotted mask has only a small set of possible partial-octet values: 0, 128, 192, 224, 240, 248, 252, 254, or 255, and after an octet becomes partial, every following subnet-mask octet must be zero. Validation is important when copying from documentation, spreadsheets, ACLs, or manually typed device settings.
Wildcard masks invert subnet-mask bits
A wildcard mask is the bitwise inverse of a subnet mask: every one becomes zero and every zero becomes one. The inverse of 255.255.255.0 is 0.0.0.255; the inverse of 255.255.255.192 is 0.0.0.63. In many routing and access-control syntaxes, a zero wildcard bit means the corresponding address bit must match, while a one bit permits variation. This does not make every wildcard expression equivalent to a CIDR block. Some systems allow non-contiguous wildcard patterns to match selected bits. RouterNAT's wildcard conversion deliberately accepts only the exact inverse of a contiguous subnet mask, because only that form maps unambiguously to one CIDR prefix.
Do not paste a wildcard mask into a subnet-mask field
Subnet and wildcard masks can look like plausible dotted IPv4 values but have opposite bit meaning. A /24 subnet mask is 255.255.255.0, while its wildcard is 0.0.0.255. Entering one where the device expects the other can create an overly broad match, an empty match, a broken route, or an unintended access-control rule. Read the field label and current vendor documentation. Common terms include subnet mask, netmask, prefix length, slash notation, inverse mask, host mask, and wildcard. RouterNAT labels every output explicitly and never assumes that a dotted value is a wildcard unless wildcard mode is selected. Preserve the input context when copying results into a change plan.
How the binary conversion works
Each dotted octet represents eight bits with positional weights 128, 64, 32, 16, 8, 4, 2, and 1. An octet value of 224 equals 128 + 64 + 32, so its binary form is 11100000. In a /19 mask, the first sixteen bits fill two octets with 255, and the next three network bits make the third octet 224; the final mask is 255.255.224.0. The remaining thirteen bits are host bits. Viewing the padded binary mask prevents decimal patterns from hiding the actual boundary and makes it easier to audit subnetting exercises, route filters, cloud ranges, and device configuration.
Total address capacity comes from host bits
If a prefix has p network bits, it leaves 32 minus p host bits. The block contains 2 raised to that host-bit count. A /24 leaves eight host bits and holds 256 addresses. A /26 leaves six and holds 64. A /30 leaves two and holds four. This is total mathematical capacity, not a promise that every address can be assigned to a device. The containing network boundary depends on the address and alignment. Gateways, redundancy, infrastructure, DHCP exclusions, provider reservations, and design policy can reduce practical client capacity. The converter reports the block size so the representation can be compared, while the subnet calculator handles a concrete address range.
Conventional usable hosts and the two-address subtraction
For ordinary IPv4 multi-access subnets from /0 through /30, the all-zero host value identifies the network and the all-one host value is conventionally the directed broadcast address. A familiar usable-host estimate therefore subtracts two from total capacity. A /24 commonly reports 254 usable hosts, and a /30 reports two. That formula is a planning convention, not a universal statement about every routed address. Providers, cloud platforms, network appliances, high-availability designs, and managed services can reserve additional addresses. RouterNAT labels the number conventional usable hosts and does not use it to decide how many clients a real network can support.
Why /31 is different
RFC 3021 permits both addresses of a /31 on an IPv4 point-to-point link. Because the link has only two endpoints and does not behave like a conventional multi-access LAN, the traditional network-and-broadcast subtraction is not applied. RouterNAT reports two usable addresses for /31 and adds an explicit note. Support depends on the equipment, operating system, and interface role. A /31 should not be assigned casually to an ordinary Wi-Fi or Ethernet client LAN, and it is not a technique for squeezing two household devices into a tiny DHCP scope. Confirm the exact platform behavior and use the address calculator when actual endpoint addresses must be identified.
Why /32 identifies one address
A /32 has thirty-two network bits and zero host bits. It represents one exact IPv4 address and uses subnet mask 255.255.255.255 with wildcard 0.0.0.0. /32 routes commonly identify loopbacks, host routes, tunnel endpoints, policy objects, or a single allowed source. It is not a conventional subnet with a network address, broadcast address, gateway, and client pool. RouterNAT reports one total and one usable address for the host-route interpretation. Device interfaces and route commands can treat /32 differently according to context, so a valid conversion does not prove that a particular configuration field accepts or routes it.
The block increment or magic number
For prefixes that end inside an octet, subtract the subnet-mask value in that octet from 256. The result is the block increment. A /26 mask ends with 192, giving an increment of 64, so aligned fourth-octet boundaries are 0, 64, 128, and 192. A /20 has third-octet mask 240 and increment 16, producing third-octet boundaries 0, 16, 32, and onward. The increment helps find networks manually, but only in the octet containing the prefix boundary. /8, /16, and /24 end exactly on octet boundaries, while /0 covers the entire IPv4 space and needs broader interpretation than a normal last-octet exercise.
Worked conversion for /27
A /27 uses twenty-seven network bits and leaves five host bits. The first three octets contain twenty-four one bits. The last octet begins with three additional ones: 11100000 equals 224. The subnet mask is 255.255.255.224 and the wildcard is 0.0.0.31. Five host bits produce 32 total addresses and 30 conventional usable hosts. The increment is 256 minus 224, or 32. If a separate IPv4 address were 192.168.1.70, its containing /27 would begin at an aligned multiple of 32; finding that boundary requires the address and belongs in the subnet calculator rather than this representation-only converter.
Worked conversion from 255.255.254.0
The first two mask octets contribute sixteen one bits. The third octet, 254, is 11111110 and contributes seven more. The complete prefix is therefore /23. Inverting the mask produces wildcard 0.0.1.255. Nine host bits yield 512 total addresses and 510 conventional usable hosts. The third-octet increment is 256 minus 254, or 2. Actual /23 network boundaries advance by two in the third octet, but the exact containing network still depends on the supplied IPv4 address. A value such as 255.254.255.0 would be rejected because a zero bit in the second octet would be followed by one bits later.
Worked conversion from wildcard 0.0.15.255
Wildcard mode first inverts the bits. 0.0.15.255 becomes subnet mask 255.255.240.0. The partial third octet 240 is 11110000 and adds four network bits to the first sixteen, producing /20. Twelve host bits create 4,096 total addresses and 4,094 conventional usable hosts. The third-octet increment is 16. This conversion is valid because the wildcard is the exact inverse of one contiguous subnet mask. A wildcard such as 0.0.5.255 can be useful in a vendor-specific bit-matching rule, but it is non-contiguous and cannot honestly be labelled as one CIDR block, so the converter rejects it.
CIDR replaced fixed class boundaries
Classless Inter-Domain Routing allows prefixes at any bit length rather than limiting networks to the historical class A, B, and C default masks. A /20 or /27 is valid without being forced into a classful boundary. Classful terminology still appears in training material and legacy interfaces, but modern routing, allocation, cloud networks, and firewall objects generally use explicit prefixes. Do not infer a mask from the first address octet when the prefix is available. For example, 10.0.0.0 can be subdivided into many prefix sizes; its membership in private 10.0.0.0/8 does not mean every local segment must use an /8 mask.
Route aggregation and longest-prefix match
CIDR enables adjacent, correctly aligned routes to be summarized under a shorter prefix, reducing routing-table entries. Aggregation is not performed by merely choosing a shorter mask: the component networks must be contiguous, alignment must match the proposed prefix, and the summary must not unintentionally cover unrelated space. Routers normally select the most specific matching route, known as longest-prefix match, when several routes cover a destination. This converter can express each candidate prefix but does not inspect route tables, prove adjacency, or generate the minimal set of ranges. Use an authorized route-planning workflow and verify that security policy, return paths, and failure domains remain correct before advertising a summary.
Where prefixes appear in routers, firewalls, and cloud networks
Routers use prefixes in interface addressing and routing. Firewalls use them for source and destination objects, though ACL syntax may require wildcard masks. VPNs use prefixes to define protected networks and split-tunnel routes. Cloud VPCs and subnets use CIDR blocks with platform-specific minimum sizes, reserved addresses, overlap restrictions, and immutable or expandable fields. Container, virtualization, Kubernetes, and overlay systems also allocate pools that can conflict with home, office, or VPN ranges. A correct representation conversion cannot detect those overlaps or platform rules. Copy the result only into a field that expects that representation, and review the provider or vendor documentation before applying it.
CIDR conversion is not subnet calculation
A prefix or mask describes which bits form the network boundary, but network and broadcast addresses require an IPv4 address as well. /24 alone cannot tell whether the intended network is 10.0.5.0/24, 192.168.1.0/24, or another aligned block. Likewise, host range, gateway, DHCP pool, and address type are not encoded in the mask. RouterNAT intentionally keeps this converter focused and directs address-based questions to the IPv4 subnet calculator. Separating the intents reduces errors: use this page to translate notation and study capacity; use the subnet page to combine an address with the prefix; use VLSM planning to divide a parent network for several requirements.
IPv6 uses prefixes but not dotted IPv4 masks
IPv6 also uses CIDR-style prefix lengths, but its addresses contain 128 bits and normal configuration does not use dotted-decimal subnet masks or IPv4 wildcard masks. A common IPv6 LAN prefix is /64, while provider delegations may be /48, /56, /60, or another size. Entering /64 here would be invalid because this converter is deliberately limited to IPv4 /0 through /32. Use the IPv6 subnet calculator for 128-bit range mathematics and the IPv6 compressor for notation. Do not convert an IPv6 prefix into an invented 32-bit dotted mask; that would discard most of the address width and produce meaningless configuration.
Common errors and a verification method
Frequent errors include omitting an octet, entering a prefix above 32, swapping wildcard and subnet masks, accepting a non-contiguous dotted mask, subtracting two from /31, treating /32 as a normal LAN, or assuming total addresses equal practical clients. Verify important work in three forms: check the prefix count, inspect the padded binary mask, and confirm the dotted mask and wildcard are exact inverses. Then use an actual sample address in a subnet calculator and compare the aligned boundary. For production changes, confirm the target platform field, save the existing configuration, change one item at a time, and retain a rollback path.
Privacy, limitations, and responsible use
All conversion logic on this page runs in local browser JavaScript after the page loads. RouterNAT does not need an IP address, hostname, credential, or router access for this calculation. The output is deterministic mathematics, but it cannot discover a live subnet, validate a DHCP server, inspect routing, detect address conflicts, authorize an ACL, or decide whether a proposed design is secure. The complete reference table shows common mathematical capacity; it does not include every provider, cloud, operating-system, or vendor reservation. Confirm current standards and authoritative product documentation for critical networks. Never paste confidential configurations or credentials into a public tool when a prefix or fictional example is sufficient.
To combine the converted prefix with a real address, use the IPv4 subnet calculator for network, broadcast, and host boundaries. The IPv4 binary converter exposes the address bits octet by octet.
For capacity-first design, choose a prefix with the network host calculator. When one parent block must serve several differently sized networks, use the VLSM subnet planner.
After selecting router and pool addresses, run the proposal through the DHCP range validator. IPv6 prefixes require the separate IPv6 subnet calculator because IPv6 uses 128 bits rather than an IPv4 dotted mask.
Privacy and responsible use
This calculation runs locally in your browser. RouterNAT does not receive or save the values entered into this tool. Use the result only for lawful network administration and troubleshooting.
Related RouterNAT guides
To understand WAN and public-address differences, read the complete CGNAT detection guide before changing NAT or port-forwarding settings.
How to use this result
Verify important changes against your router manual, ISP documentation, or an authorized network administrator. This utility provides planning guidance and does not connect to, scan, or modify your router.

Comments
Leave a Comment
Your email address will not be published. Comments are reviewed before appearing.