CIDR Calculator API
Calculate network, broadcast, subnet mask and host counts from CIDR notation, or summarize any IP range into minimal CIDR blocks. IPv4 + IPv6 — free.
The CIDR Calculator is also available as a free REST API. Send a POST request with a JSON body to https://dot.tools/api/tools/cidr-calculator — no authentication, no API key, CORS enabled. Successful calls return { "ok": true, "result": { … } }; failures return HTTP 400 or 422 with an error body.
Request body
| Field | Type | Required | Description |
|---|---|---|---|
mode | "cidr" | "range" | required | "cidr" analyzes one CIDR block (network, broadcast, masks, host counts). "range" summarizes an arbitrary start-end IP range into the minimal set of CIDR blocks. |
cidr | string | optional | Required when mode is "cidr". IPv4 or IPv6 CIDR notation, e.g. "192.0.2.0/24" or "2001:db8::/32". IPv4 rejects leading zeros and short/hex forms; IPv6 accepts one "::" compression and embedded IPv4 tails. |
normalize | boolean | optional | When false (default), a CIDR with host bits set (e.g. "10.0.0.1/8") fails with errorCode HOST_BITS_SET and a suggestion field carrying the network CIDR. When true, the address is masked to its network and the result has normalized=true. |
start | string | optional | Required when mode is "range". First address of the range, IPv4 or IPv6. |
end | string | optional | Required when mode is "range". Last address of the range, same family as start and not smaller. |
Response
| Field | Type | Required | Description |
|---|---|---|---|
family | unknown | required | Detected address family, null on error. |
error | unknown | required | Human-readable error message, null on success. |
errorCode | unknown | required | Machine-readable error code such as HOST_BITS_SET, INVALID_CIDR, FAMILY_MISMATCH or RANGE_ORDER. |
suggestion | unknown | required | On HOST_BITS_SET, the normalized network CIDR to retry with (or pass normalize=true). |
cidr | unknown | required | The normalized CIDR that was analyzed (cidr mode). |
network | unknown | required | Network (first) address of the block. |
broadcast | unknown | required | Broadcast address. IPv4 /30 and shorter only — null for IPv6, /31 (RFC 3021) and /32. |
firstUsable | unknown | required | First usable host address. |
lastUsable | unknown | required | Last usable host address. |
totalHosts | unknown | required | Total addresses in the block, as a decimal string (can exceed 2^53). |
usableHosts | unknown | required | Usable host addresses as a decimal string: total-2 for IPv4 /30 and shorter, 2 for /31, 1 for /32; total for IPv6, 2 for /127, 1 for /128. |
subnetMask | unknown | required | Dotted subnet mask, IPv4 only. |
wildcardMask | unknown | required | Dotted wildcard (inverse) mask, IPv4 only. |
normalized | boolean | required | True when the input had host bits set and was masked to its network address. |
rangeStart | unknown | required | Start address of the analyzed range (range mode). |
rangeEnd | unknown | required | End address of the analyzed range (range mode). |
rangeCount | unknown | required | Number of addresses in the range, as a decimal string. |
cidrs | unknown | required | Minimal exact CIDR decomposition of the range (range mode). |
Example request
curl -X POST https://dot.tools/api/tools/cidr-calculator \
-H 'Content-Type: application/json' \
-d '{
"mode": "cidr",
"cidr": "192.168.0.0/24"
}'Sample response
{
"ok": true,
"result": {
"family": "ipv4",
"error": null,
"errorCode": null,
"suggestion": null,
"cidr": "192.168.0.0/24",
"network": "192.168.0.0",
"broadcast": "192.168.0.255",
"firstUsable": "192.168.0.1",
"lastUsable": "192.168.0.254",
"totalHosts": "256",
"usableHosts": "254",
"subnetMask": "255.255.255.0",
"wildcardMask": "0.0.0.255",
"normalized": false,
"rangeStart": null,
"rangeEnd": null,
"rangeCount": null,
"cidrs": null
}
}Use the free CIDR Calculator in your browser, read the CIDR Calculator guide, or import the full OpenAPI specification.