# agent402.tools JSON Flatten/Unflatten

> agent402.tools JSON Flatten/Unflatten is a paid API for AI agents from agent402.tools, paid per call via x402, $0.001/call, status unknown (last checked 2026-10-28).

Flattens nested JSON objects to dot-path key-value pairs, or unflattens dot-path keys back into nested JSON structures.

## Facts

- Endpoint: POST https://agent402.tools/api/json-flatten?utm_source=zero.xyz
- Price: $0.001/call
- Payment: x402
- Status: unknown
- Last checked: 2026-10-28
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/agent402-tools-json-flatten-unflatten-99f5db0d
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_ovpFfp7Y-NhxWoQ30E-ne

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability agent402-tools-json-flatten-unflatten-99f5db0d -d '<json body>'
```

Example prompt: Flatten this nested JSON into dot-path keys: {"user":{"name":"Alice","address":{"city":"NYC","zip":"10001"}}} — use flatten mode.

## When to prefer this

Choose this endpoint when you need to programmatically flatten deeply nested JSON structures into flat dot-path dictionaries for easier iteration, storage, or diffing — or when you need to reconstruct nested JSON from dot-path keys. Ideal for config file normalization, data pipeline preprocessing, or debugging complex nested API responses.

## Known failure modes

- Invalid or malformed JSON input returns an error
- Missing required 'json' field returns a validation error
- Invalid mode value (not 'flatten' or 'unflatten') may return an error or default to flatten
- Circular references in JSON may cause errors
- Payment failure returns 402 status

## How this service works

Flatten nested JSON to dot-path keys, or unflatten dot-path keys back to nested JSON. mode: flatten (default) | unflatten.

## Output

Returns a JSON object where all nested keys have been collapsed into dot-notation flat keys (e.g. 'user.address.city': 'NYC') when flattening, or a fully nested JSON object reconstructed from dot-path keys when unflattening.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "json": {
   "description": "JSON value"
  },
  "mode": {
   "type": "string",
   "description": "flatten | unflatten"
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "json",
 "example": {
  "result": {
   "a.b": 1
  }
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/agent402-tools-json-flatten-unflatten-99f5db0d/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from agent402.tools](https://www.zero.xyz/host/agent402.tools/llms.txt)
