IP Subnet Calculator

Network engineers carving a VPC into subnets, sysadmins writing firewall rules, and developers debugging a Docker or Kubernetes network all need the same core facts: given this address and prefix, what is the network, what is the broadcast, which host range is usable, and does the address fall in a private or public block.

Paste an IPv4 address with an optional CIDR prefix and this calculator returns the full subnet breakdown, plus a mask-to-CIDR converter, a wildcard-to-mask inverter, and a range-to-CIDR expander. All arithmetic runs locally, so internal network ranges never leave the machine.

Network
—
Broadcast
—
First host
—
Last host
—
Usable hosts
—
Total hosts
—
Dotted mask
—
Wildcard
—
Class
—
Scope
—
Network bits
—
Host bits
—
Binary view
Field 32-bit binary
IP—
Mask—
Network—
Broadcast—

Mask to CIDR

Wildcard to mask

Range to CIDR

How the subnet math works

An IPv4 address is a 32-bit unsigned integer. The CIDR prefix tells you how many of those high bits belong to the network. The mask is built by setting the top prefix bits to one and the remaining host bits to zero, then the network address is the bitwise AND of the IP and the mask. The broadcast is the bitwise OR of the network and the wildcard, where the wildcard is the exact inverse of the mask.

Total hosts is two raised to the host-bit count. For prefixes of thirty or fewer, usable hosts subtracts two for the reserved network and broadcast addresses. A /31 is the point-to-point exception where both addresses are usable, and a /32 is a single host route. The calculator applies these rules automatically so the numbers match what your router or cloud console reports.

The binary view shows the same four values as dotted groups of eight bits, which is the fastest way to see which octet the prefix boundary falls in and why a /22 spans four third-octet addresses while a /23 spans only two.

Before and after: a typical /24 calculation

Input, a host address inside a private /24:

192.168.1.100/24

Output, the full breakdown:

network:   192.168.1.0/24
broadcast: 192.168.1.255
first:     192.168.1.1
last:      192.168.1.254
usable:    254
total:     256
mask:      255.255.255.0
wildcard:  0.0.0.255
class:     C
scope:     private (RFC 1918)

Who uses this subnet calculator

Developers

  • Size a Docker or Kubernetes pod CIDR and confirm the usable host count before deploying.
  • Verify that a hardcoded /16 in a terraform module actually covers every subnet you planned.
  • Use the binary view to explain to a teammate why a /22 gives you four times the hosts of a /24.

Production

  • Carve a VPC into equally sized subnets and check the first and last host before writing security groups.
  • Expand a DHCP scope range into CIDR blocks when configuring a new site router.
  • Confirm a VPN tunnel address sits inside the usable range and not on the broadcast.

Workflow

  • Convert a wildcard mask from an access-list into a CIDR prefix and paste it into the main calculator.
  • Expand a start-to-end range into CIDR blocks, then validate each block with the mask-to-CIDR tool.
  • Pair with the CIDR calculator when you need to aggregate or split blocks programmatically.

Common mistakes when calculating subnets

  • Using the broadcast address as a host. The last address in a /24 is the broadcast and cannot be assigned to a device. Always use the last usable host shown in the calculator, which is one less than the broadcast for prefixes of /30 and shorter.
  • Forgetting the /31 point-to-point exception. Older documentation says a /31 has no usable hosts. That was true before RFC 3021, but modern routers use /31 on point-to-point links and both addresses are assignable. The calculator reflects the modern behavior.
  • Confusing a wildcard mask with a subnet mask. A wildcard is the bitwise inverse, so 0.0.0.255 is a wildcard, not a mask. If you paste a wildcard into a mask field you get a nonsensical result. Use the dedicated wildcard-to-mask box to invert it first.
  • Assuming private addresses always start with 10. RFC 1918 defines three private blocks: 10.0.0.0/8, 172.16.0.0/12, and 192.168.0.0/16. The 172.16 block is easy to miss because it only spans 172.16 through 172.31. The scope badge tells you which block an address falls in.

Best practices for subnet planning

  • 1.Leave room to grow. Size each subnet one or two prefix lengths larger than your current need so you do not re-IP when headcount doubles.
  • 2.Document the first and last usable host for every subnet in your runbook, so on-call engineers do not have to recompute them during an incident.
  • 3.Use /31 for point-to-point links and /32 for loopback interfaces to conserve address space in large designs.
  • 4.Expand DHCP ranges with the range-to-CIDR tool so your scopes align to clean prefix boundaries and routing summarization works.

Frequently asked questions

What does this IP subnet calculator compute?

Given an IPv4 address with an optional CIDR prefix, the tool returns the network address, broadcast address, first and last usable host, total and usable host counts, dotted-decimal mask, wildcard mask, IP class, and a private or loopback flag. It also prints the binary form of the IP, mask, network, and broadcast so you can see exactly which bits are the network portion and which are the host portion.

How do I convert a subnet mask to CIDR?

Paste the dotted mask into the mask-to-CIDR box. The tool checks that the mask bits are contiguous, meaning a run of ones followed by a run of zeros with no gaps, then counts the leading ones. A mask of 255.255.255.0 has 24 leading ones so it maps to /24. A mask with non-contiguous bits such as 255.0.255.0 is rejected because it is not a valid subnet mask.

How do I convert a wildcard mask to a subnet mask?

Paste the wildcard into the wildcard-to-mask box. A wildcard is the bitwise inverse of the subnet mask, so the tool flips every bit and prints the dotted result. The wildcard 0.0.0.255 inverts to 255.255.255.0. This is the form used in Cisco access-lists and is the reverse of the mask shown in the main calculator.

How does range to CIDR expansion work?

Paste a start and end IPv4 address. The tool finds the largest power-of-two block aligned at the start address that stays within the end address, emits that as a CIDR, then repeats from the next address until the entire range is covered. A range of 192.168.1.0 to 192.168.1.255 collapses to a single 192.168.1.0/24. An unaligned range such as .10 to .100 expands to multiple blocks.

What is the difference between total hosts and usable hosts?

Total hosts is two raised to the number of host bits, which includes the network address and the broadcast address. Usable hosts subtracts those two reserved addresses, so a /24 has 256 total and 254 usable. For /31 and /32 the standard reservation does not apply: a /31 is used for point-to-point links and both addresses are usable, and a /32 is a single host route with one usable address.

Why does the calculator flag private and loopback addresses?

Private ranges are defined in RFC 1918: 10.0.0.0/8, 172.16.0.0/12, and 192.168.0.0/16, plus the link-local 169.254.0.0/16. The loopback range is 127.0.0.0/8. Knowing whether an address is private tells you it will not route on the public internet, which matters when you are designing a VPN, a container network, or a firewall rule.

Does this tool send my IP data to a server?

No. All arithmetic runs in JavaScript inside your browser tab using 32-bit unsigned integer math. The page makes no network request with your input and the addresses are discarded when the tab closes. You can disconnect from the internet after the page loads and the calculator still works, which makes it safe to paste internal network ranges.

Related network and developer tools