Skip to content
PithLab

↑↓ to move · Enter to open · Esc to close

CIDR to IP Range Converter API

Convert IPv4/IPv6 CIDR blocks to first–last ranges, ranges to the minimal CIDR list, merge overlapping CIDRs and ranges, or list every address in a small block.

POST /api/v1/tools/cidr-ip-range-converterMCP cidr_ip_range_converterNetwork Tools

Convert CIDR blocks to first and last IP and address count, turn IP ranges into the fewest CIDRs, merge overlapping CIDRs and list IPs. IPv4 and IPv6.

Input

Send these as a JSON object. Unknown fields are rejected.

input
One CIDR (10.0.0.0/22, 2001:db8::/48) or range (10.0.0.0 - 10.0.3.255) per line; # starts a comment. (string, up to 100000 characters, required)
mode
cidr-to-range: each CIDR as "cidr: first - last (count)". range-to-cidr: each range as CIDR blocks. merge: aggregate all lines into the fewest CIDRs. expand: list every address (at most 4,096). (string, one of cidr-to-range, range-to-cidr, merge, expand, default "cidr-to-range")
curl https://pithlab.com/api/v1/tools/cidr-ip-range-converter \n  -H "Authorization: Bearer $PITHLAB_KEY" \n  -H "Content-Type: application/json" \n  -d '{"input":"192.168.0.0 - 192.168.2.255\n10.0.0.0/23\n10.0.2.0/23","mode":"merge"}'
Example response
{
  "ok": true,
  "result": {
    "output": "10.0.0.0/22\n192.168.0.0/23\n192.168.2.0/24",
    "lines": [
      "10.0.0.0/22",
      "192.168.0.0/23",
      "192.168.2.0/24"
    ],
    "errors": []
  }
}