RevealTheme logo

CIDR Calculator

Enter how many hosts you need and this calculator returns the smallest IPv4 CIDR prefix that fits them, along with the total addresses, usable hosts, and how much space you would waste.

Smallest CIDR fitting 50 hosts/26
Total addresses in /2664
Usable hosts62
Address space wasted12

How to use this tool

  1. 1

    Type the number of hosts you need to address into the 'Hosts needed' field.

  2. 2

    Read the 'Smallest CIDR fitting' row to get the prefix length (for example /26).

  3. 3

    Check the 'Total addresses' and 'Usable hosts' rows to confirm the block is big enough.

  4. 4

    Look at the 'Address space wasted' row to see how many addresses you would leave unused at that prefix.

What does this CIDR host-count calculator actually do?

This is the inverse of a typical CIDR calculator. Instead of taking an IP and prefix and showing you the network address, broadcast, mask, and host range, it starts from a host count and works backwards to the smallest IPv4 prefix that fits. CIDR (Classless Inter-Domain Routing, RFC 4632) sizes subnets in powers of two, so a subnet is defined by its prefix length: a /26 holds 64 addresses, a /25 holds 128, and so on. The math here is exactly 32 minus the ceiling of log2(hosts + 2): the +2 reserves the network and broadcast addresses, and the ceiling rounds up to the next power of two. For 50 hosts you need at least 52 addresses, which rounds up to 64, giving a /26 with 62 usable hosts and 12 wasted. The 'wasted' figure (total minus 2 minus your hosts) is what makes this tool useful for capacity planning rather than just lookups. Note that the 32 is hardcoded, so this is IPv4 only with no IPv6 support, and the calculation always subtracts 2 for network and broadcast.

Common use cases

  • Sizing a new office VLAN by entering the expected device count and picking the prefix that leaves a little headroom.

  • Quickly checking whether a /24 is overkill for a subnet that only needs 30 hosts.

  • Comparing the wasted-address count across host estimates before you carve up a parent block.

  • Teaching subnetting students why 50 hosts needs 64 addresses and not 50.

  • Planning IP allocation for a fleet of IoT devices and confirming the block will not run out as you scale.

  • Sanity-checking a colleague's subnet proposal by reproducing the host-to-prefix math in seconds.

Frequently asked questions

Why does it subtract 2 from the total addresses?
Every standard IPv4 subnet reserves the first address as the network identifier and the last as the broadcast address, so neither can be assigned to a host. This tool always subtracts these 2, which is correct for typical subnets.
Is the usable-host count right for /31 and /32 blocks?
No. The calculator always subtracts 2, but RFC 3021 /31 point-to-point links use both addresses, and a /32 is a single host. For those edge cases the 'usable hosts' figure will be misleading, so use a full subnet calculator.
Does this calculate the subnet mask, network address, or host range?
No. It only converts a host count into a prefix length plus total, usable, and wasted address counts. It does not output dotted-decimal masks, network or broadcast addresses, or the usable host range.
Does it support IPv6?
No. The host bits are calculated against a fixed 32-bit address space, so it is IPv4 only. IPv6 prefixes are sized very differently and are not supported here.
What happens if I enter a very large or empty host count?
There is no input validation. Very large counts drive the prefix toward 0 or negative, which is not a real subnet, and an empty field is treated as 0, which yields a /32. Stick to realistic host counts for sensible results.
Is there a Calculate button?
No. The table recalculates reactively as you type in the 'Hosts needed' field, so results update immediately with no button to press.
Is my data sent anywhere?
No. The calculation runs entirely in your browser with plain JavaScript. Nothing you type is uploaded or stored on a server.

Related tools