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

FieldTypeRequiredDescription
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.
cidrstringoptionalRequired 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.
normalizebooleanoptionalWhen 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.
startstringoptionalRequired when mode is "range". First address of the range, IPv4 or IPv6.
endstringoptionalRequired when mode is "range". Last address of the range, same family as start and not smaller.

Response

FieldTypeRequiredDescription
familyunknownrequiredDetected address family, null on error.
errorunknownrequiredHuman-readable error message, null on success.
errorCodeunknownrequiredMachine-readable error code such as HOST_BITS_SET, INVALID_CIDR, FAMILY_MISMATCH or RANGE_ORDER.
suggestionunknownrequiredOn HOST_BITS_SET, the normalized network CIDR to retry with (or pass normalize=true).
cidrunknownrequiredThe normalized CIDR that was analyzed (cidr mode).
networkunknownrequiredNetwork (first) address of the block.
broadcastunknownrequiredBroadcast address. IPv4 /30 and shorter only — null for IPv6, /31 (RFC 3021) and /32.
firstUsableunknownrequiredFirst usable host address.
lastUsableunknownrequiredLast usable host address.
totalHostsunknownrequiredTotal addresses in the block, as a decimal string (can exceed 2^53).
usableHostsunknownrequiredUsable 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.
subnetMaskunknownrequiredDotted subnet mask, IPv4 only.
wildcardMaskunknownrequiredDotted wildcard (inverse) mask, IPv4 only.
normalizedbooleanrequiredTrue when the input had host bits set and was masked to its network address.
rangeStartunknownrequiredStart address of the analyzed range (range mode).
rangeEndunknownrequiredEnd address of the analyzed range (range mode).
rangeCountunknownrequiredNumber of addresses in the range, as a decimal string.
cidrsunknownrequiredMinimal 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.