About the IP Range to CIDR API

API Version: 1.9

Convert an IPv4 address range into the exact list of CIDR blocks that covers it, or summarize a list of CIDR blocks, ranges and single addresses into the smallest exact set.

Every response includes both the exact list and the single smallest covering block, together with the addresses a covering block would add that were not in your input. Use the exact list for firewall rules and allowlists.

This is the API for the IP Range to CIDR converter.

Endpoints

https://networkcalc.com/api/range/{input}

Converts an IP range to CIDR blocks, or summarizes a list of CIDR blocks. Accepts ranges (`10.0.0.5-10.0.3.200`), CIDR blocks (`10.0.0.0/24`) and single addresses, separated by commas.

Example request and response
curl https://networkcalc.com/api/range/192.168.1.10-192.168.1.20

{
  "status": "OK",
  "meta": {},
  "input": {
    "items": 1,
    "runs": 1,
    "addresses": 11,
    "first_address": "192.168.1.10",
    "last_address": "192.168.1.20"
  },
  "exact": {
    "count": 4,
    "addresses": 11,
    "extra_addresses": 0,
    "blocks": [
      {
        "cidr": "192.168.1.10/31",
        "network_address": "192.168.1.10",
        "last_address": "192.168.1.11",
        "addresses": 2,
        "subnet_mask": "255.255.255.254",
        "wildcard_mask": "0.0.0.1"
      },
      {
        "cidr": "192.168.1.12/30",
        "network_address": "192.168.1.12",
        "last_address": "192.168.1.15",
        "addresses": 4,
        "subnet_mask": "255.255.255.252",
        "wildcard_mask": "0.0.0.3"
      },
      {
        "cidr": "192.168.1.16/30",
        "network_address": "192.168.1.16",
        "last_address": "192.168.1.19",
        "addresses": 4,
        "subnet_mask": "255.255.255.252",
        "wildcard_mask": "0.0.0.3"
      },
      {
        "cidr": "192.168.1.20/32",
        "network_address": "192.168.1.20",
        "last_address": "192.168.1.20",
        "addresses": 1,
        "subnet_mask": "255.255.255.255",
        "wildcard_mask": "0.0.0.0"
      }
    ]
  },
  "covering": {
    "cidr": "192.168.1.0/27",
    "network_address": "192.168.1.0",
    "last_address": "192.168.1.31",
    "addresses": 32,
    "subnet_mask": "255.255.255.224",
    "wildcard_mask": "0.0.0.31",
    "extra_addresses": 21,
    "extra_percent": 65.6,
    "is_exact": false,
    "extra_ranges": [
      {
        "start": "192.168.1.0",
        "end": "192.168.1.9",
        "addresses": 10
      },
      {
        "start": "192.168.1.21",
        "end": "192.168.1.31",
        "addresses": 11
      }
    ],
    "extra_ranges_total": 2
  },
  "map": {
    "start": 3232235776,
    "size": 32,
    "used": [
      {
        "offset": 10,
        "size": 11
      }
    ]
  }
}

Parameters

{input}

(Required) An IPv4 range as start-end, a CIDR block, a single address, or a comma-separated list of any of these. Up to 1,000 items. Blocks with host bits set are treated as their network block and reported in meta.normalized.

Example: https://networkcalc.com/api/range/192.168.1.10-192.168.1.20

Response Codes

200
OK - Success.
400
NO_INPUT_SPECIFIED - The {input} parameter was not specified.
400
INVALID_INPUT - One or more items are not valid IPv4 addresses, CIDR blocks or ranges. The offending items are listed in invalid.
400
TOO_MANY_ITEMS - The request contained more than 1,000 items.
400
TOO_MANY_BLOCKS - The exact result would need more than 5,000 CIDR blocks.

Response Formats

{
  "status": "[string] The status of the request.",
  "input": {
    "items": "[number] The number of items in the request.",
    "runs": "[number] The number of contiguous runs the items merge into.",
    "addresses": "[number] The number of distinct addresses in the input.",
    "first_address": "[string] The lowest address in the input.",
    "last_address": "[string] The highest address in the input."
  },
  "exact": {
    "count": "[number] The number of CIDR blocks in the exact list.",
    "addresses": "[number] The addresses the exact list covers. Always equal to input.addresses.",
    "blocks": "[array] The exact CIDR blocks. See RangeBlock"
  },
  "covering": {
    "cidr": "[string] The smallest single CIDR block that contains every input address.",
    "network_address": "[string] The first address of the covering block.",
    "last_address": "[string] The last address of the covering block.",
    "addresses": "[number] The number of addresses in the covering block.",
    "subnet_mask": "[string] The covering block's subnet mask.",
    "wildcard_mask": "[string] The covering block's wildcard mask.",
    "is_exact": "[boolean] true when the covering block contains exactly the input addresses and nothing else.",
    "extra_addresses": "[number] The number of addresses in the covering block that were not in the input.",
    "extra_percent": "[number] extra_addresses as a percentage of the covering block.",
    "extra_ranges": "[array] The ranges of extra addresses, up to 50. Each has start, end and addresses.",
    "extra_ranges_total": "[number] The total number of extra ranges, including any beyond the 50 listed."
  },
  "map": {
    "size": "[number] The size of the covering block, for drawing it to scale.",
    "used": "[array] Where the input addresses sit inside the covering block, each as an  and __TEXT\t__DATA\t__OBJC\tothers\tdec\thex."
  }
}
{
  "cidr": "[string] The block in CIDR notation.",
  "network_address": "[string] The first address in the block.",
  "last_address": "[string] The last address in the block.",
  "addresses": "[number] The number of addresses in the block.",
  "subnet_mask": "[string] The subnet mask in dotted-decimal notation.",
  "wildcard_mask": "[string] The wildcard (inverted) mask in dotted-decimal notation."
}