Skip to main content

Output Schemas

An output schema defines the exact JSON structure you want Meter to return from extractions. Instead of getting whatever field names the AI chooses, you specify the fields, types, and nesting — and Meter maps the extracted data to match.

When to use output schemas

  • You need consistent field names across different strategies (e.g., all product scrapers return price, not cost or product_price)
  • You want type coercion (prices as numbers, not strings like "$19.99")
  • Your downstream system expects a specific JSON shape
  • You’re using strategy groups and want uniform output across all members

Defining a schema

A schema is a JSON object where keys are field names and values are type strings:
{
  "title": "string",
  "price": "number",
  "in_stock": "boolean",
  "tags": "array",
  "image_url": "string"
}

Supported types

TypeDescriptionCoercion behavior
stringText valueConverts to string, None if empty
numberDecimal numberStrips $, , £, commas; parses float (e.g., "$19.99"19.99)
floatSame as numberAlias for number
integerWhole numberSame stripping as number, then rounds to int (e.g., "225 points"225)
intSame as integerAlias for integer
booleanTrue/false"true", "yes", "1"True; "false", "no", "0"False
arrayList of valuesIf string, splits on commas; if single value, wraps in list

Nested schemas

You can define nested structures:
{
  "product": {
    "name": "string",
    "pricing": {
      "amount": "number",
      "currency": "string"
    }
  },
  "seller": {
    "name": "string",
    "rating": "float"
  }
}
Meter flattens extracted data internally using underscore-separated keys (e.g., product_name, product_pricing_amount) and then re-nests it to match your schema structure.

Wrapper array pattern

For schemas with a single top-level key containing an array, Meter automatically wraps results:
{
  "listings": [
    {
      "title": "string",
      "price": "number"
    }
  ]
}
This produces output like:
{
  "listings": [
    {"title": "MacBook Pro", "price": 1999},
    {"title": "iPad Air", "price": 599}
  ]
}

Where schemas apply

Strategy generation

Pass an output_schema when generating a strategy to guide extraction and get consistent output from the start:
result = client.generate_strategy(
    url="https://shop.com/products",
    description="Extract product listings",
    name="Product Scraper",
    output_schema={
        "product_name": "string",
        "price": "number",
        "rating": "float",
        "in_stock": "boolean"
    }
)

# Preview data matches the schema structure
for item in result["preview_data"]:
    print(f"{item['product_name']}: ${item['price']}")

Strategy groups

Apply a schema to all strategies in a group at once:
client.apply_group_schema(
    group_id="group-uuid",
    output_schema={
        "title": "string",
        "price": "number",
        "url": "string"
    }
)
See Strategy Groups for details.

Bulk upload

When using Bulk Upload, you can define an output schema that applies to all generated strategies in the batch.

URL field handling

Meter automatically detects URL fields in your schema (keys containing url, link, or href) and optimizes extraction to capture the href attribute rather than link text. You don’t need to configure this — it happens automatically.

Examples

E-commerce product schema

{
  "product_name": "string",
  "price": "number",
  "original_price": "number",
  "discount_percentage": "integer",
  "rating": "float",
  "review_count": "integer",
  "in_stock": "boolean",
  "image_url": "string",
  "product_url": "string"
}

Job listing schema

{
  "title": "string",
  "company": "string",
  "location": "string",
  "salary_min": "integer",
  "salary_max": "integer",
  "job_type": "string",
  "posted_date": "string",
  "apply_url": "string",
  "tags": "array"
}

Next steps

Strategy Groups

Apply schemas to many strategies at once

Filtering

Filter extraction results post-processing

Strategies

Learn how strategies use output schemas

Bulk Upload

Create many strategies with a shared schema

Need help?

Email me at mckinnon@meter.sh