Subnet Hosts Calculator
Enter a CIDR prefix length and the subnet hosts calculator returns the number of usable IPv4 addresses — the network and broadcast addresses already subtracted.
Usable hosts at a glance
Enter the prefix length (the /n after an address) and the calculator returns 2^(32 − prefix) − 2 — the count of addresses you can actually assign to devices.
Two reserved addresses
Every ordinary subnet loses two addresses — the network address and the broadcast address — so a /24 gives 254 usable hosts, not 256.
What does the subnet hosts calculator do?
From CIDR prefix to usable addresses
The subnet hosts calculator turns a CIDR prefix length into the number of usable IPv4 host addresses inside that subnet. An IPv4 address has 32 bits; the prefix length (the /n in 192.168.1.0/24) says how many of those bits identify the network, leaving the rest to number individual hosts. Raise two to the power of those leftover host bits and you get the total addresses in the block — then subtract two, because the first address is reserved as the network address and the last as the broadcast address. The result is the count you can hand out to real devices: a /24 holds 254 usable hosts, a /30 just 2, and a /16 a full 65,534.
Enter a CIDR prefix length from 0 to 30 and the calculator instantly returns the usable host count, 2^(32 − prefix) − 2.
The usable host count is two raised to the number of host bits, minus the two reserved addresses. The host bits are simply 32 minus the prefix length.
usableHosts = 2^(32 − prefix) − 2The prefix length controls everything: each bit you give back to the host portion doubles the number of addresses. Drop from /24 to /23 and the usable count jumps from 254 to 510; go the other way to /25 and it halves to 126. The minus two is constant — it always removes the network and broadcast addresses, regardless of subnet size.
Suppose you have the subnet 192.168.1.0/24 and want to know how many devices it can address.
Find the host bits
32 − 24 = 8 — the prefix uses 24 bits for the network, leaving 8 for hosts.
Raise two to the host bits
2^8 = 256 — the total number of addresses in the block.
Subtract the reserved addresses
256 − 2 = 254 usable hosts — one address is the network address (192.168.1.0) and one is the broadcast address (192.168.1.255).
The usable host count tells you how many devices a subnet can address, and because the number doubles with every extra host bit, the common subnet sizes form a familiar ladder: a /30 holds 2 usable hosts (the classic point-to-point link), a /29 holds 6, a /28 holds 14, a /27 holds 30, a /26 holds 62, a /25 holds 126, and a /24 holds 254. Each step toward a smaller prefix doubles the capacity, while each step toward a larger prefix halves it. That doubling is why network designers think in powers of two: if you need to fit 100 devices, a /25 (126 hosts) is the tightest fit, since a /26 (62 hosts) is too small. Always size up to the next prefix that comfortably exceeds your device count, leaving room for growth, gateways, and management interfaces.
The formula is exact for ordinary subnets, but two short prefixes are special cases worth knowing.
The /31 and /32 special cases
This calculator subtracts the network and broadcast addresses, which is correct for every subnet from /0 to /30. It does not apply to /31 or /32: a /31 has only two addresses and, under RFC 3021, both are used for a point-to-point link with no network or broadcast reserved, while a /32 is a single-address host route. The classic formula would give 0 and −1 for these, so the result is clamped to 0 — treat /31 and /32 as point-to-point and single-host cases rather than ordinary subnets. The count is also a maximum: individual addresses may be set aside for a gateway or other infrastructure.