ForHosting KIT · Developer Utilities

Subnet usable host calculator

This subnet usable host calculator converts an IPv4 CIDR prefix length or dotted-decimal subnet mask into a clear capacity result.

● BetaFree · in your browser
Use it from WebAPIEmailTelegramApp soon

It reports the normalized prefix, the equivalent mask, the total number of addresses in the subnet, and the usable host count after excluding the network and broadcast addresses. Use it when planning address space, checking an exam answer, documenting a network, or validating an infrastructure configuration. The calculation is deterministic and requires no network lookup, so the same input always produces the same result.

Enter either a CIDR prefix or subnet mask

Provide a prefix as 24 or /24, or enter a dotted-decimal mask such as 255.255.255.0. The calculator accepts every IPv4 prefix from 0 through 32, including the boundary values. When you supply a dotted mask, each octet must be between 0 and 255 and its binary form must be contiguous: all one bits must come before all zero bits. A value such as 255.0.255.0 is rejected because it cannot represent a conventional CIDR subnet mask. The result normalizes both accepted forms into a prefix length and a dotted mask, which makes it easy to compare configuration files that use different notation. Whitespace around the value is ignored, but extra text, IPv4 addresses with an attached prefix, negative numbers, decimals, and prefixes greater than 32 are intentionally rejected. This strict input behavior helps prevent a plausible-looking capacity result from being produced for an ambiguous or mistyped network setting. Use the subnet, prefix, or mask field name when calling the API; subnet is the primary documented field.

Understand total addresses and usable hosts

An IPv4 address has 32 bits. A prefix fixes the specified number of leading network bits and leaves the remaining bits available for addresses inside the subnet. The total is therefore two raised to the power of 32 minus the prefix length. For /24, eight bits remain, producing 256 total addresses. This capability follows the requested traditional host-count convention and subtracts two addresses: one for the network identifier and one for the broadcast address. A /24 consequently reports 254 usable host addresses. Very small subnets need special attention. Because the calculation always excludes network and broadcast, /31 and /32 return zero usable host addresses here. Some point-to-point deployments use the two addresses of a /31 under a special standards-based convention, and a host route identifies one address with /32, but those operational interpretations are outside this calculator’s stated rule. The explicit total remains useful: /31 has two total addresses and /32 has one. The largest accepted network, /0, has 4,294,967,296 total addresses and 4,294,967,294 after the two exclusions.

Apply the result to network planning

Use the usable count as an initial capacity check, then account for addresses reserved by your actual environment. Gateways, load balancers, DNS services, appliances, virtual IPs, cloud-provider reservations, and growth margins can all reduce the number available to endpoints beyond the network and broadcast exclusions performed here. For example, a /26 provides 64 total addresses and 62 under the traditional usable-host formula, but it may support fewer than 62 application instances after platform reservations. The normalized mask is also useful when translating a CIDR-based design into equipment or documentation that expects dotted-decimal notation. In automation, compare the returned usable_host_addresses value with the number of required devices and fail deployment early when capacity is insufficient. Store the prefix_length and subnet_mask alongside that decision so reviewers can see exactly which interpretation was used. This tool counts addresses only: it does not calculate a network address or broadcast address because no host IP is supplied, and it does not inspect routes, VLANs, DHCP pools, IPv6 prefixes, or live equipment. API execution costs $0.002 per request, while the deterministic calculation remains suitable for quick interactive checks.

Size a new IPv4 subnet

Compare the usable host count with device demand and leave room for infrastructure reservations and growth.

Validate network documentation

Convert a dotted mask to its normalized prefix and confirm that the documented capacity is mathematically consistent.

Check infrastructure automation

Reject a planned prefix when its traditional usable-address count is below the deployment requirement.

What input formats are accepted?

Use an integer prefix from 0 to 32, the same prefix with a leading slash, or a contiguous dotted-decimal IPv4 subnet mask.

How is the usable host count calculated?

The calculator finds 2^(32-prefix) total addresses and subtracts the network and broadcast addresses, never returning less than zero.

Why does /31 report zero usable hosts?

This capability applies the requested traditional exclusion rule. It does not apply the special point-to-point interpretation that can use both /31 addresses.

Does it calculate network and broadcast addresses?

No. It counts addresses from a mask or prefix alone; calculating endpoints would also require an IPv4 address.

What does an API request cost?

Each API request costs $0.002. The algorithm uses no external network service or probabilistic model.

Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.

POSThttps://api.kit.forhosting.com/misc2/subnet-host-count

Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.

curl -X POST https://api.kit.forhosting.com/misc2/subnet-host-count \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"subnet":"/24"}'
{
  "subnet": "/24"
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "misc2.subnet_host_count",
  "status": "queued",
  "_links": {
    "result": "/tasks/tsk_…/result"
  }
}

The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.

Per request$0.002

Published price — no tokens, no invented credits. A failed task is never charged.

HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

Read the full KIT documentation →