# IPv4 CIDR parse

`ipv4-cidr-parse` · version 1.0.0 · URLs & IP addresses · free, no key needed

Parse an IPv4 CIDR block into its network, broadcast, netmask, wildcard mask, usable host range and address counts.

**Use when you need to: ipv4 cidr parse · ipv4 subnet info · ipv4 cidr to network details.**

## Supported

- ipv4 cidr parse
- ipv4 subnet info
- ipv4 cidr to network details

## Not supported

- IPv6
- host-address CIDR notation (host bits must be zero)
- dotted netmask input

## Behavior

- cidr is dotted-decimal/prefix with prefix a canonical decimal integer 0-32 and no leading zeros except 0.
- The network address must have host bits zero; otherwise the tool throws "cidr host bits must be zero".
- total_count is the canonical decimal string 2^(32-prefix), the size of the block including network and broadcast.
- usable_host_count follows RFC 3021: /32 has 1 usable host (itself), /31 has 2 (both addresses, no reserved network/broadcast), /0-/30 reserve the first address as network and the last as broadcast.
- first_usable_host/last_usable_host equal network/broadcast for /31 and /32.

## Input

- `cidr` (string, required): max length 18

## Output

- `network` (string, required): max length 15
- `broadcast` (string, required): max length 15
- `netmask` (string, required): max length 15
- `wildcard_mask` (string, required): max length 15
- `prefix` (integer, required): min 0; max 32
- `first_usable_host` (string, required): max length 15
- `last_usable_host` (string, required): max length 15
- `usable_host_count` (string, required): pattern `^(0|[1-9][0-9]*)$`
- `total_count` (string, required): pattern `^(0|[1-9][0-9]*)$`

## Limits

- max cidr length: 18
- prefix min: 0
- prefix max: 32

## Example

Request input:

```json
{
  "cidr": "192.168.1.0/24"
}
```

Response:

```json
{
  "result": {
    "network": "192.168.1.0",
    "broadcast": "192.168.1.255",
    "netmask": "255.255.255.0",
    "wildcard_mask": "0.0.0.255",
    "prefix": 24,
    "first_usable_host": "192.168.1.1",
    "last_usable_host": "192.168.1.254",
    "usable_host_count": "254",
    "total_count": "256"
  }
}
```

## How to call it

### MCP

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

```json
{
  "id": "ipv4-cidr-parse",
  "version": "1.0.0",
  "input": {
    "cidr": "192.168.1.0/24"
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/ipv4-cidr-parse/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"cidr":"192.168.1.0/24"}'
```

The machine-readable contract is at [/v1/tools/ipv4-cidr-parse/versions/1.0.0](/v1/tools/ipv4-cidr-parse/versions/1.0.0).

### CLI

```sh
node cli.mjs run ipv4-cidr-parse 1.0.0 --input input.json --base-url https://computefirst.net
```

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

## Related tools

- [IPv6 CIDR parse](/tools/ipv6-cidr-parse): Parse an IPv6 CIDR block into its canonical network address, prefix, first/last address, and total address count.
- [IPv4 CIDR contains](/tools/ipv4-cidr-contains): Test whether one IPv4 CIDR block fully contains another IPv4 CIDR block.
- [IPv4 CIDR overlap](/tools/ipv4-cidr-overlap): Test whether two IPv4 CIDR blocks overlap (share at least one address).
- [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.
- [IPv4 parse](/tools/ipv4-parse): Parse a canonical dotted-decimal IPv4 address into octets and a uint32 integer string.
