# JSON unflatten

`json-unflatten` · version 1.0.0 · JSON & JSONL · free, no key needed

Reconstruct a JSON value from a map of RFC 6901 JSON Pointers to leaves.

**Use when you need to: json unflatten · unflatten json pointers · reconstruct json from pointers.**

## Supported

- json unflatten
- unflatten json pointers
- reconstruct json from pointers
- expand json pointer map

## Not supported

- json pointer get
- json pointer set
- sparse arrays
- read files
- fetch urls

## Behavior

- Own keys of pointers are RFC 6901 JSON Pointers; values are leaves.
- The empty pointer denotes the entire document and must be the only key.
- A pointer cannot be both a leaf and a prefix of another pointer.
- The same parent cannot be used as both an array and an object.
- Array indexes are canonical decimal tokens forming a dense range 0..n-1.
- Reconstructed object keys are in lexicographic UTF-16 order of unescaped names; arrays are in index order.
- Prototype-like keys are ordinary own keys on null-prototype objects.
- Leaf values are null, boolean, string, safe integer, or an empty object or array.

## Input

- `pointers` (object, required)

## Output

- `value` (any, required)

## Limits

- max pointers: 5000
- max depth: 16
- max output bytes: 1048576

## Example

Request input:

```json
{
  "pointers": {
    "/name": "Ada",
    "/tags/0": "math",
    "/tags/1": "writer",
    "/address/city": "London"
  }
}
```

Response:

```json
{
  "result": {
    "value": {
      "address": {
        "city": "London"
      },
      "name": "Ada",
      "tags": [
        "math",
        "writer"
      ]
    }
  }
}
```

## How to call it

### MCP

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

```json
{
  "id": "json-unflatten",
  "version": "1.0.0",
  "input": {
    "pointers": {
      "/name": "Ada",
      "/tags/0": "math",
      "/tags/1": "writer",
      "/address/city": "London"
    }
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/json-unflatten/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"pointers":{"/name":"Ada","/tags/0":"math","/tags/1":"writer","/address/city":"London"}}'
```

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

### CLI

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

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

## Related tools

- [JSON flatten](/tools/json-flatten): Flatten a JSON value into a null-prototype map keyed by RFC 6901 JSON Pointers.
- [JSON pointer list](/tools/json-pointer-list): List RFC 6901 pointers to every reachable JSON node, root first.
- [JSON array drop keys](/tools/json-array-drop-keys): Remove specific keys from each object in a JSON array.
- [JSON array group count](/tools/json-array-group-count): Group an array of JSON objects by exact keys and return the count.
- [JSON array index by](/tools/json-array-index-by): Convert an array of objects into a single object indexed by a specific key.
- [JSON array project](/tools/json-array-project): Select specific keys from each object in a JSON array.
