JSON to Zod

Turn JSON into Zod validation schemas, with refined checks for emails, URLs, UUIDs and dates.

Pay by wallet (x402) json-to-zod

Example

Example answer
{
  "zod_schema": "import { z } from \"zod\";\n\nconst rootSchema = z.object({\n  name: z.string(),\n  value: z.number().int(),\n});",
  "root_schema": "rootSchema",
  "schema_count": 1
}

Inputs

FieldTypeRequiredWhat it is
jsonanyYesJSON string or object
root_namestringNo—

Output fields

How reliably each field appears in a successful answer.

FieldTypeAppears
zod_schemastringAlways (present in every successful answer)
root_schemastringAlways (present in every successful answer)
schema_countintegerAlways (present in every successful answer)

How to call it

The same tool through each route. MCP clients reach it through Strale’s server at https://api.strale.io/mcp; the call below is what the agent sends.

# Needs an API key. max_price_cents caps what this call may cost.
curl -X POST https://api.strale.io/v1/do \
  -H "Authorization: Bearer $STRALE_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
    "capability_slug": "json-to-zod",
    "inputs": {
      "json": "{\"name\": \"Test\", \"value\": 42}"
    },
    "max_price_cents": 5
  }'

Limitations

  • String format constraints are not inferred

    Generates Zod schemas from JSON samples — string format constraints (email, URL, date) are not inferred automatically

    What to do instead: Add .email(), .url(), or .datetime() refinements manually for fields that require format validation