Sanity Schema Mapper icon

Sanity Schema Mapper

Takes a Sanity schema and input data, then transforms it into a valid Sanity document.

Sanity Schema Mapper

AI-generated

Summary

Transform incoming data into valid Sanity documents using a provided Sanity JSON schema and custom field mappings.

Inputs

  • Sanity Document Schema (required) — Paste the JSON schema for your Sanity document type, including "name" and "fields" properties, as defined in your Sanity project schema files.
  • Field Mappings — Define one or more mappings from incoming data fields or expressions to fields in the Sanity schema. Each mapping specifies a target Sanity field path (like 'title' or 'slug.current') and an input value or expression to map.

Output shape

A list of JSON objects, each representing a transformed Sanity document that conforms to the provided schema. Each output item contains a JSON object with an '_type' set to the schema's name and fields populated based on the mappings.

The node parses the provided schema once and validates it has the required structure. For each incoming item, it applies all mapping rules, transforming values according to the Sanity field types (e.g., slug, reference, image). If the schema JSON is invalid or missing required properties, the node errors. Output items maintain pairing to their corresponding input item.

Links

Discussion