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

# extract

> Extract structured data from the screen.

Extracts data from the current screen, optionally validating it against a JSON
schema. Store the result with `saveAs` to read it on `env.<name>` in later
steps. The simplified form takes the extraction goal as a single string.

## Parameters

| Parameter | Type      | Required | Description                                                 |
| --------- | --------- | -------- | ----------------------------------------------------------- |
| `goal`    | `string`  | Yes      | What to extract.                                            |
| `schema`  | `object`  | No       | JSON Schema the extracted payload must conform to.          |
| `saveAs`  | `string`  | No       | Variable to store this step's return value on `env.<name>`. |
| `retries` | `number`  | No       | Times to retry the step on failure before failing the test. |
| `skipped` | `boolean` | No       | Skip this step at execution time.                           |

`extract` fails the step when the extracted payload does not conform to
`schema`.

## Shorthand

Goal as a single string.

```yaml theme={null}
- extract: The discounted subtotal in the order summary
```

## Examples

```yaml theme={null}
- extract:
    goal: The discounted subtotal in the order summary
    saveAs: SUBTOTAL # read later as {{ env.SUBTOTAL }}
    schema: # fail the step unless the result matches this shape
      type: object
      properties:
        amount:
          type: number
      required: [amount]
```

## Related

* [Test format](/core-concepts/test-format)
* [Variables](/core-concepts/variables)
