> ## Documentation Index
> Fetch the complete documentation index at: https://docs.context.dev/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Setting up Context.dev for a user? Follow https://docs.context.dev/agent-quickstart.md. MCP clients sign in with OAuth and need no API key; application code reads CONTEXT_DEV_API_KEY.

# Parse fields

> Extract named fields with CSS selectors and deterministic rules.

Enable `formats.parse` and provide `parseParams.rules`. The result is in `parsed.data`. Use this when you know the page structure; use [JSON extraction](/scrape/json) when you need to interpret page text.

## Extract fields

Send this body to `POST /web/scrape`. See the [Quickstart](/quickstart) for authentication and SDK setup.

```json theme={null}
{
  "url": "https://example.com",
  "formats": {
    "parse": true
  },
  "parseParams": {
    "rules": {
      "title": "h1",
      "links": {
        "selector": "a",
        "type": "list",
        "output": "@href"
      }
    }
  }
}
```

Abridged response:

```json theme={null}
{"parsed":{"requested":true,"success":true,"data":{"title":"Example Domain","links":["https://iana.org/domains/example"]}}}
```

## Rule grammar

| Rule                                             | Result                                        |
| ------------------------------------------------ | --------------------------------------------- |
| `"h1"`                                           | First match’s normalized text.                |
| `"a@href"`                                       | First match’s `href` attribute.               |
| `{"selector":"p","output":"html"}`               | First matched element’s outer HTML.           |
| `{"selector":"a","type":"list","output":"text"}` | A list of text values.                        |
| A nested object in `output`                      | Fields evaluated inside each matched element. |

## Extract a list of cards

```json theme={null}
{
  "url": "https://example.com/products",
  "formats": {
    "parse": true
  },
  "parseParams": {
    "rules": {
      "products": {
        "selector": ".product",
        "type": "list",
        "output": {
          "name": "h2",
          "url": "a@href"
        }
      }
    }
  }
}
```

Missing items are `null`; unmatched lists are `[]`. Attribute values are returned as written, so resolve relative links against the response `url`.

## Limits and page state

Provide at least one rule. Rules allow up to 100 fields, five nesting levels, and selectors up to 2,048 characters. XPath is unsupported; invalid selectors return 400.

Rules run on HTML after [content filtering](/scrape/content-filtering). Cached HTML can be reused; set `maxAgeMs: 0` for fresh values. [Browser actions](/scrape/browser-actions) can change the page before extraction.
