CIDR / Subnet Calculator API
IPv4 / IPv6 subnet calculator: network, broadcast, netmask, host range and count; check if IPs are inside, split subnets, merge lists, range to CIDR.
Give a network as cidr (192.168.1.0/24, 10.0.0.1/255.255.255.0, 2001:db8::/48) and get the network and broadcast address, netmask and wildcard mask, first / last address and usable host range, total addresses and usable hosts (RFC 3021 /31 and /32 handled), binary mask, class, address type (private, CGNAT, documentation, multicast…), the reverse DNS zone and the previous / next networks of the same size. IPv6 addresses are shown compressed and expanded, with the number of /64 subnets.
Other actions (chosen from the parameters, or with action): contains checks whether one or many ip (addresses or CIDRs) are inside the network; split cuts it into subnets by new prefix, number of subnets or hosts per subnet (up to 4096 listed); range turns first-last into the smallest list of CIDR blocks; merge takes a list of CIDRs, addresses and ranges (up to 10,000), merges overlapping and adjacent blocks into the minimal set and reports duplicates and overlaps.
Pure calculation with 128-bit integers: no lookup, nothing stored. For the owner and location of an address use /v1/ip, for cloud and Tor ranges /v1/ip-intel.
Parameters
| Name | In | Type | Required | Default | |
|---|---|---|---|---|---|
cidr | query|body | string | no | Network (10.0.0.0/8, 10.1.2.3/255.0.0.0, 2001:db8::/32), a single address, or first-last for action=range. Also in the path: /v1/cidr/10.0.0.0%2F8. | |
action | query|body | string | no | info, contains, split, range or merge (guessed from the other parameters when absent). | |
ip | query|body | string | no | contains: address(es) or CIDR(s) to test, comma or newline separated (up to 1000). | |
prefix | query|body | number | no | split: new prefix length. | |
subnets | query|body | number | no | split: number of subnets wanted (rounded up to a power of two). | |
hosts | query|body | number | no | split: hosts needed per subnet. | |
limit | query|body | number | no | 256 | split: subnets listed (1-4096). |
list | body|query | array | no | merge: CIDRs, addresses and ranges a-b (array or separated by new lines, commas, spaces), up to 10,000. |
Example
curl "https://apibox.io.vn/v1/cidr?cidr=192.168.10.0/26" \
-H "Authorization: Bearer YOUR_API_KEY"const res = await fetch('https://apibox.io.vn/v1/cidr?cidr=192.168.10.0/26', {
method: 'GET',
headers: {
Authorization: 'Bearer YOUR_API_KEY',
},
});
const data = await res.json();
console.log(data);import requests
res = requests.get(
"https://apibox.io.vn/v1/cidr?cidr=192.168.10.0/26",
headers={"Authorization": "Bearer YOUR_API_KEY"},
timeout=30,
)
print(res.json())<?php
$ch = curl_init('https://apibox.io.vn/v1/cidr?cidr=192.168.10.0/26');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer YOUR_API_KEY'],
]);
$response = curl_exec($ch);
print_r(json_decode($response, true));Response
{
"action": "info",
"cidr": "192.168.10.0/26",
"version": 4,
"prefix": 26,
"network": "192.168.10.0",
"netmask": "255.255.255.192",
"wildcard": "0.0.0.63",
"broadcast": "192.168.10.63",
"first_address": "192.168.10.0",
"last_address": "192.168.10.63",
"first_host": "192.168.10.1",
"last_host": "192.168.10.62",
"total_addresses": 64,
"usable_hosts": 62,
"netmask_binary": "11111111.11111111.11111111.11000000",
"network_hex": "0xc0a80a00",
"integer_range": [
3232238080,
3232238143
],
"class": "C",
"type": "private",
"reverse_zone": "10.168.192.in-addr.arpa",
"previous_network": "192.168.9.192/26",
"next_network": "192.168.10.64/26"
}
Use cases
- Plan VPC subnets and VLANs (split a /16 into /24 blocks)
- Clean and merge firewall or allowlist CIDR lists
- Check whether client IPs fall inside an office or partner range
- Convert IP ranges from logs or registries into CIDR notation
FAQ
How are /31 and /32 handled?
A /31 has two usable addresses (RFC 3021, point-to-point links) and no broadcast; a /32 is a single host.
What if the address has host bits set?
The network is computed from it (192.168.1.130/26 → 192.168.1.128/26) and the input address is shown with a note.
Is IPv6 supported everywhere?
Yes: info, contains, split, range and merge all work with IPv6, and lists can mix IPv4 and IPv6.
Related APIs
IP Geolocation
Look up the country, region, city, coordinates, ASN and ISP of any IPv4 or IPv6 address – or your own IP – in one fast JSON call.
DNSDNS Lookup
Query A, AAAA, MX, TXT, NS, CNAME, SOA, CAA, SRV and more for any domain, or reverse-lookup an IP (PTR), via DNS over HTTPS. Clean JSON output.
@Email Validator
Validate e-mail addresses: syntax, MX/A records, ~120k disposable domains, role accounts, free providers and typo hints like gmial.com → gmail.com.