# IPv4 range to cidrs

`ipv4-range-to-cidrs` · version 1.0.0 · URLs & IP addresses · free, no key needed

Convert an arbitrary IPv4 address range into the minimal list of CIDR blocks that exactly covers it.

**Use when you need to: ipv4 range to cidr · convert ipv4 range to cidrs · summarize ipv4 address range.**

## Supported

- ipv4 range to cidr
- convert ipv4 range to cidrs
- summarize ipv4 address range

## Not supported

- IPv6
- hyphenated single-string ranges

## Behavior

- first_address and last_address are canonical dotted-decimal IPv4 addresses; first_address must not exceed last_address as a uint32.
- cidrs is the minimal ordered list of non-overlapping CIDR blocks (largest-first at each step) whose union is exactly [first_address, last_address].
- A single address (first_address equal to last_address) yields one /32 block.

## Input

- `first_address` (string, required): max length 15; pattern `^(?:0|[1-9][0-9]{0,2})(?:\.(?:0|[1-9][0-9]{0,2})){3}$`
- `last_address` (string, required): max length 15; pattern `^(?:0|[1-9][0-9]{0,2})(?:\.(?:0|[1-9][0-9]{0,2})){3}$`

## Output

- `cidrs` (array of string, required): max items 64; each max length 18
- `count` (integer, required): min 1; max 64

## Limits

- max address length: 15
- max output blocks: 64

## Example

Request input:

```json
{
  "first_address": "192.168.1.9",
  "last_address": "192.168.1.11"
}
```

Response:

```json
{
  "result": {
    "cidrs": [
      "192.168.1.9/32",
      "192.168.1.10/31"
    ],
    "count": 2
  }
}
```

## How to call it

### MCP

Connect `https://computefirst.net/mcp` ([setup](/docs#connect)), then call `execute` with:

```json
{
  "id": "ipv4-range-to-cidrs",
  "version": "1.0.0",
  "input": {
    "first_address": "192.168.1.9",
    "last_address": "192.168.1.11"
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/ipv4-range-to-cidrs/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"first_address":"192.168.1.9","last_address":"192.168.1.11"}'
```

The machine-readable contract is at [/v1/tools/ipv4-range-to-cidrs/versions/1.0.0](/v1/tools/ipv4-range-to-cidrs/versions/1.0.0).

### CLI

```sh
node cli.mjs run ipv4-range-to-cidrs 1.0.0 --input input.json --base-url https://computefirst.net
```

Get the client at [/clients/cli/](/clients/cli/).

## Related tools

- [IPv6 range to cidrs](/tools/ipv6-range-to-cidrs): Convert an arbitrary IPv6 address range into the minimal list of CIDR blocks that exactly covers it.
- [IPv4 address offset](/tools/ipv4-address-offset): Add a signed integer offset to an IPv4 address, throwing if the result leaves the IPv4 address space.
- [IPv4 CIDR aggregate](/tools/ipv4-cidr-aggregate): Merge a list of IPv4 CIDR blocks into the minimal equivalent list of non-overlapping CIDR blocks.
- [IPv4 CIDR parse](/tools/ipv4-cidr-parse): Parse an IPv4 CIDR block into its network, broadcast, netmask, wildcard mask, usable host range and address counts.
- [IPv4 in CIDR](/tools/ipv4-in-cidr): Test whether a canonical IPv4 address lies in a CIDR prefix whose host bits are zero.
- [IPv4 mask convert](/tools/ipv4-mask-convert): Convert between an IPv4 prefix length, dotted subnet netmask, and dotted wildcard (host) mask.
