JSON to Zod / Pydantic Schema Generator

Paste a JSON sample and generate a typed Zod schema or Pydantic model for structured LLM outputs.

import { z } from 'zod';

export const Schema = z.object({
  id: z.string(),
  name: z.string(),
  email: z.string(),
  isActive: z.boolean(),
  signupDate: z.string(),
  tags: z.array(z.string()),
  address: z.object({
    street: z.string(),
    city: z.string(),
    zipCode: z.string()
  }),
  orders: z.array(z.object({
    orderId: z.string(),
    total: z.number(),
    items: z.number().int()
  }))
});

export type Schema = z.infer<typeof Schema>;

Schemas are inferred from the sample's shape only — arrays use the type of their first element, and fields present in other array items or absent here won't be reflected. Review before using in production.

About JSON to Zod / Pydantic

Structured LLM outputs (OpenAI's response format, function/tool calling, Instructor, LangChain output parsers) need a schema to validate against. Writing that schema by hand from an example payload is repetitive — this tool infers a Zod schema or Pydantic model directly from a sample JSON response, including nested objects and arrays.

Key Features

  • Generates a Zod schema with inferred TypeScript types, or a Pydantic model with nested classes.
  • Handles nested objects and arrays, converting keys to idiomatic snake_case for Python with alias mapping preserved.
  • 100% client-side — your sample JSON never leaves the browser.