Type generator · structured outputs
JSON to Pydantic, Zod, TypeScript & JSON Schema
Paste a JSON example and get four typed outputs at once — a Pydantic v2 model, a Zod schema, a TypeScript interface, and a JSON Schema. It runs entirely in your browser, so nothing you paste ever leaves your device. Built for LLM structured outputs and typed API contracts.
Updated Jul 10, 2026 · Built by Wayne
What it does
One JSON sample in, four typed schemas out
This is a free, private JSON-to-types generator. You paste a representative JSON object and it infers a type model, then emits it four ways: a Pydantic v2 BaseModel for Python, a Zod schema for TypeScript runtime validation, a TypeScript interface for compile-time types, and a JSON Schema (draft 2020-12) for API and LLM contracts. Everything happens locally in JavaScript — there is no backend, so your data stays on your machine.
It is written for the structured-output era. When you constrain an LLM's response with OpenAI or Anthropic structured outputs, or expose a tool over the Model Context Protocol, the shape is defined by a JSON Schema — and you usually want a matching Pydantic or Zod validator on the receiving end. Hand-writing all of those and keeping them aligned is tedious and easy to get subtly wrong. Paste one example response and get all four, consistent by construction.
How to use it
Three steps, no setup
Paste your JSON
Drop a real example response or API payload into the left editor. Name the root type if you want — the default is User.
Pick a target
Switch between TypeScript, Pydantic, Zod and JSON Schema tabs. Output regenerates as you type, instantly.
Copy and paste
Hit copy and drop the result into your codebase. Nested objects come out as named, ready-to-use types.
Worked examples
Real input, real output
Two examples generated by this exact tool. The first shows nested-object inference; the second shows how an array of objects is merged, with keys missing from some elements marked optional.
{
"id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"name": "Ada Lovelace",
"email": "ada@example.com",
"age": 36,
"profile": {
"bio": "Mathematician",
"website": "https://ada.example.com"
},
"nickname": null
}
from typing import Any, Optional
from pydantic import AnyUrl, BaseModel, EmailStr
from uuid import UUID
class Profile(BaseModel):
bio: str
website: AnyUrl
class User(BaseModel):
id: UUID
name: str
email: EmailStr
age: int
profile: Profile
nickname: Optional[Any] = None
{
"order_id": 1024,
"items": [
{ "sku": "A-1", "qty": 2, "price": 9.99, "gift": false },
{ "sku": "B-2", "qty": 1, "price": 20, "note": "fragile" }
]
}
export interface Item {
sku: string;
qty: number;
price: number;
gift?: boolean;
note?: string;
}
export interface Order {
order_id: number;
items: Item[];
}
Note how price becomes number (9.99 and 20 unify to a float), and gift and note become optional because each appears in only one of the two items.
Why structured outputs
Keep your schema and validators in sync
A structured-output call to an LLM is only as reliable as the schema behind it. OpenAI's structured outputs and Anthropic's tool use both take a JSON Schema and guarantee the model returns JSON that conforms to it. The 2025 Model Context Protocol revision went further and made an output schema a first-class part of a tool definition. So the JSON Schema is no longer an afterthought — it is the contract.
The problem is that the schema rarely lives alone. Your Python worker wants a Pydantic model to parse the response into typed objects. Your TypeScript frontend or edge function wants a Zod schema to validate at runtime and a matching interface for the compiler. When you edit one by hand, the others drift. Generating all four from a single example keeps them aligned, and gives you a correct starting point that infers nesting, arrays, optionality, integers versus floats, and common string formats like email, UUID and date-time.
Because it is entirely client-side, you can safely paste production payloads, auth responses or anything sensitive — the JSON is parsed in your own browser and never transmitted.
FAQ
Common questions
Is it safe and private? Does my JSON get uploaded?+
Nothing is uploaded. All parsing and code generation runs in your browser with plain JavaScript. There is no server, no network request, and no analytics on your input. Open the page, disconnect from the internet, and it still works.
Does it support Pydantic v2?+
Yes. The Python output targets Pydantic v2 (BaseModel), using Optional and List from typing, EmailStr and AnyUrl for string formats, and datetime, date and UUID where detected. Nested objects become their own classes, defined in dependency order so the module imports cleanly without forward-reference errors.
Does it handle nested objects and arrays?+
Yes. Nested objects become named types derived from their key. Arrays are inspected element by element: a homogeneous array becomes a typed list, an array of objects is merged into a single model where keys missing from some elements are marked optional, and mixed arrays become a union type.
How are optional and nullable fields detected?+
A field missing from some objects in an array is marked optional. A field whose value is null becomes nullable. A field that is only ever null cannot have its real type inferred from the sample, so it is marked optional with an unknown type (any, Optional[Any], z.any()) rather than guessed.
What JSON Schema version does it output?+
JSON Schema draft 2020-12. Objects include a properties map, a required array for non-optional keys, and additionalProperties: false, which is the shape OpenAI structured outputs expects. Detected string formats (email, uuid, date-time, date, uri) are emitted as format keywords.
Who built this?+
Wayne — an AI builder. This is the first tool on waynetools, a small collection of fast, private, no-signup utilities for developers. More are on the way; each one runs client-side and stays out of your data.