# IPv4 format

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

Format a uint32 integer string or four octets as a canonical dotted-decimal IPv4 address.

**Use when you need to: ipv4 format · format ipv4 dotted decimal · uint32 or octets to ipv4.**

## Supported

- ipv4 format
- format ipv4 dotted decimal
- uint32 or octets to ipv4

## Not supported

- IPv6
- hexadecimal
- CIDR prefixes
- leading-zero dotted decimal as input
- hostnames

## Behavior

- Input is exactly one of integer or octets; unknown fields are rejected; both or neither throw.
- integer is a canonical integer string n with 0 <= n <= 4294967295; -0 is accepted as 0.
- octets is an array of exactly four JSON integers 0-255 (Number.isInteger).
- address is dotted decimal without leading zeros (0 is written 0).
- ipv4-format(ipv4-parse(a)) yields a for every canonical dotted-decimal address a.

## Input

- object

## Output

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

## Limits

- integer min: 0
- integer max: 4294967295
- octet count: 4
- octet min: 0
- octet max: 255

## Example

Request input:

```json
{
  "integer": "3232235777"
}
```

Response:

```json
{
  "result": {
    "address": "192.168.1.1"
  }
}
```

## How to call it

### MCP

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

```json
{
  "id": "ipv4-format",
  "version": "1.0.0",
  "input": {
    "integer": "3232235777"
  }
}
```

### HTTP (no key)

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

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

### CLI

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

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

## Related tools

- [IPv4 parse](/tools/ipv4-parse): Parse a canonical dotted-decimal IPv4 address into octets and a uint32 integer string.
- [IPv6 format](/tools/ipv6-format): Format 8 hextets or a 128-bit integer string as the RFC 5952 canonical compressed IPv6 address.
- [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 parse](/tools/ipv4-cidr-parse): Parse an IPv4 CIDR block into its network, broadcast, netmask, wildcard mask, usable host range and address counts.
- [IPv4 mask convert](/tools/ipv4-mask-convert): Convert between an IPv4 prefix length, dotted subnet netmask, and dotted wildcard (host) mask.
- [IPv4 range to cidrs](/tools/ipv4-range-to-cidrs): Convert an arbitrary IPv4 address range into the minimal list of CIDR blocks that exactly covers it.
