Zod schema generator from JSON
Validating external data — API responses, webhook payloads, config files — with Zod is one of the cleanest patterns in modern TypeScript, but hand-writing the schema for a deeply nested object is tedious and error-prone. This tool takes a real JSON sample and infers a matching Zod v3 schema, including nested objects, arrays, nulls, and a generated TypeScript type alias.
How it works
The generator recursively walks your parsed JSON. Strings, numbers, and
booleans map to z.string(), z.number(), and z.boolean(). Objects become
z.object({ ... }) with each key recursed into. Arrays use their first element
to infer an element schema and emit z.array(...). When you supply an array of
objects, the tool unions the keys across all items: keys missing from some items
become .optional(), and any field that is sometimes null becomes
.nullable(). The result is a named schema plus a z.infer type alias.
Tips and notes
- Give a full sample. Optionality is inferred from what is present. The more complete and representative your JSON, the more accurate the schema.
- Paste arrays for better optionality. An array of several objects lets the tool detect which fields are sometimes absent or null.
- Refine afterwards. Add
.email(),.min(),.uuid(), and other refinements once the structure is right — the tool gives you the skeleton. - Local only. Your payload never leaves the browser.