# JSON sources in recipes (/guides/json-sources)

Recipes can read JSON that the target page already exposes. Use an embedded `application/json` script when the data is in the HTML, or `network_json` when the browser observes a same-origin JSON response that is not present in the HTML.

The recipe reads selected JSON values; it does not execute page JavaScript or provide a general-purpose network request API.

## Embedded JSON [#embedded-json]

Select exactly one JSON script and address a value with an RFC 6901 JSON Pointer. A common source is Next.js Pages Router data in `script#__NEXT_DATA__`.

```json
{
  "target": "/title",
  "source": {
    "type": "json",
    "selectors": ["script#__NEXT_DATA__"],
    "pointer": "/props/pageProps/article/title"
  },
  "multiple": false,
  "required": true,
  "transforms": [{ "type": "trim" }]
}
```

For a collection, point to an array and define relative fields for each item:

```json
{
  "target": "/news",
  "source": {
    "type": "json",
    "selectors": ["script#__NEXT_DATA__"],
    "pointer": "/props/pageProps/news"
  },
  "multiple": true,
  "required": true,
  "fields": [
    {
      "target": "/title",
      "source": { "type": "json", "pointer": "/title" },
      "multiple": false,
      "required": true,
      "transforms": [{ "type": "trim" }]
    },
    {
      "target": "/url",
      "source": { "type": "json", "pointer": "/url" },
      "multiple": false,
      "required": true,
      "transforms": []
    }
  ]
}
```

The selector must match one script with `type="application/json"`. Use a specific selector or script ID rather than a broad selector that can match multiple documents.

## Captured network JSON [#captured-network-json]

Use `network_json` for a JSON API response observed by the browser:

```json
{
  "target": "/headline",
  "source": {
    "type": "network_json",
    "endpoint": { "method": "GET", "path": "/api/article" },
    "pointer": "/article/title"
  },
  "multiple": false,
  "required": true,
  "transforms": [{ "type": "trim" }]
}
```

The endpoint must be an exact origin-relative `GET` path. Do not use an absolute URL, query string, fragment, template, or wildcard. For an array of objects, the collection source carries the endpoint and nested fields use relative pointers within each item.

Capture is enabled automatically when a recipe needs `network_json`. The request runs with browser rendering and does not use the result cache; an HTTP route is promoted to its browser equivalent. Only same-origin, non-navigation `GET` responses with a `2xx` status, an `application/json` content type, and an explicit `Content-Length` are eligible. Service-worker responses are not eligible. Capture is bounded by the platform limits in [Limits](/resources/limits).

Only the selected method, path, and parsed JSON value are exposed to the recipe. Query values, headers, cookies, and full URLs are not part of the source value, and unselected response bodies are not returned as public results.

## Pointer rules [#pointer-rules]

- A pointer starts with `/`; for example, `/items/0/title` selects one array item.
- Escape `/` in a property name as `~1` and `~` as `~0`.
- Root and empty pointers are not supported.
- JSONPath, wildcards, filters, regular expressions, `eval`, JSONP, and framework-specific data loaders are not supported.
- Invalid, ambiguous, or oversized documents fail the recipe rather than being guessed.