# JSON Flatten API
> Flatten and unflatten JSON. Turn a deeply nested JSON object into a single-level map of dot-notation keys (a.b.c → value, arrays become a.0, a.1), and turn a flat dot-notation map back into the original nested structure. Choose the delimiter (dot, slash, anything), limit the depth, or keep arrays intact. Perfect for environment variables, i18n/translation keys, preparing JSON for CSV or spreadsheet export, analytics event properties, config diffing and form serialisation. Pure local processing — no key, no third-party service, instant. Live. 3 endpoints. Distinct from JSON validation/formatting, JSONPath querying and type inference.

## Authentication
All requests require your oanor API key in the `x-oanor-key` header. Get one at https://www.oanor.com/developer/keys.

```bash
curl -H "x-oanor-key: oanor_live_…" "https://api.oanor.com/flatten-api/..."
```

## Pricing
- **Free** (Free) — 1,220 calls/Mo, 2 req/s
- **Starter** ($4/Mo) — 14,000 calls/Mo, 8 req/s
- **Pro** ($24/Mo) — 154,000 calls/Mo, 20 req/s
- **Mega** ($60/Mo) — 790,000 calls/Mo, 50 req/s

## Endpoints

### Flatten

#### `GET /v1/flatten` — Flatten nested JSON to dot-notation

**Parameters:**
- `json` (query, required, string) — Nested JSON object Example: `{"a":{"b":{"c":1}},"list":[{"x":1}]}`
- `delimiter` (query, optional, string) — Key delimiter (default .)
- `safe` (query, optional, string) — true to keep arrays intact

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/flatten-api/v1/flatten?json=%7B%22a%22%3A%7B%22b%22%3A%7B%22c%22%3A1%7D%7D%2C%22list%22%3A%5B%7B%22x%22%3A1%7D%5D%7D"
```

**Response:**
```json
{
    "data": {
        "keys": 2,
        "flattened": {
            "a.b.c": 1,
            "list.0.x": 1
        }
    },
    "meta": {
        "timestamp": "2026-06-02T16:51:53.757Z",
        "request_id": "f15803e1-f8eb-46ed-b9ae-7a05bbbbe8fb"
    },
    "status": "ok",
    "message": "Flatten nested JSON",
    "success": true
}
```

#### `GET /v1/unflatten` — Unflatten dot-notation JSON

**Parameters:**
- `json` (query, required, string) — Flat dot-notation object Example: `{"a.b.c":1,"list.0.x":1}`
- `delimiter` (query, optional, string) — Key delimiter (default .)

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/flatten-api/v1/unflatten?json=%7B%22a.b.c%22%3A1%2C%22list.0.x%22%3A1%7D"
```

**Response:**
```json
{
    "data": {
        "unflattened": {
            "a": {
                "b": {
                    "c": 1
                }
            },
            "list": [
                {
                    "x": 1
                }
            ]
        }
    },
    "meta": {
        "timestamp": "2026-06-02T16:51:53.865Z",
        "request_id": "920033d0-4efe-4084-b2d4-187b293d0448"
    },
    "status": "ok",
    "message": "Unflatten dot-notation JSON",
    "success": true
}
```

### Meta

#### `GET /v1/meta` — Spec

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/flatten-api/v1/meta"
```

**Response:**
```json
{
    "data": {
        "auth": "none upstream; this gateway requires x-api-key",
        "name": "JSON Flatten API",
        "note": "Flatten a nested JSON object to single-level dot-notation keys and back. /v1/flatten?json={\"a\":{\"b\":1}} → {\"a.b\":1} (options: delimiter, max_depth, safe=true to keep arrays); /v1/unflatten?json={\"a.b\":1} → {\"a\":{\"b\":1}}. Great for env vars, i18n keys, CSV/spreadsheet export prep and analytics events. Instant, nothing stored.",
        "source": "Local JSON flattening (flat) — no key, no upstream",
        "endpoints": 3
    },
    "meta": {
        "timestamp": "2026-06-02T16:51:53.970Z",
        "request_id": "7089987c-1f73-4b10-81da-b2a281e4977a"
    },
    "status": "ok",
    "message": "Meta",
    "success": true
}
```


---
Marketplace page: https://www.oanor.com/api/flatten-api
OpenAPI spec: https://www.oanor.com/api/flatten-api/openapi.json
