JSON to Zod Schema Generator
- This tool runs entirely in your browser. Nothing you enter or upload is sent to a server.
JSON sample
Tab indents · Shift+Tab outdents · Esc then Tab moves on
Zod schema
Your Zod schema shows up here
Paste or type on the left, upload a file, or drop one onto the input.
JSON & data
- JSON to TypeScriptTypeScript interfaces from JSON
- YAML to JSONConvert YAML configs to JSON
- JSON to YAMLConvert JSON to clean YAML
- JSON to CSV ConverterTurn a JSON array into a spreadsheet
- CSV to JSON ConverterTurn CSV rows into JSON objects
- JSON to XML ConverterTurn JSON into well-formed XML
- XML to JSON ConverterTurn XML into JSON, with attributes
About this tool
Zod lets you validate data at runtime and infer TypeScript types from the same schema. This tool writes the first draft of that schema from a real JSON sample, so you don’t have to type every field by hand.
With format detection on, string values that look like emails, URLs, UUIDs, dates or ISO date-times get the matching refinement, and whole numbers get .int(). Fields missing from some array items become .optional(). For a sample with "email": "asha@example.com", "joined": "2026-01-15", "id": 7 and "score": 4.5, the output has z.string().email(), z.string().date(), z.number().int() and z.number(). A field that is null in one item and a string in another becomes .nullable().
The output imports z from "zod" and exports both the schema and its inferred type. The schema is named after the root with a Schema suffix: a root called User gives userSchema and export type User = z.infer<typeof userSchema>. Change the root name box to rename both.
Remember that the generator sees only your sample. If a number in the sample happens to be whole, .int() is added even though the API may later send 4.5; one stray value can make the schema too strict, so turn off format detection or relax the line by hand. Likewise, a string that is always one of a few values is better written as z.enum([...]), which the tool cannot know. Treat the result as a draft and adjust it. Everything runs in your browser.
Frequently asked questions
Which Zod version is the output for?
The generated code uses the standard z.object / z.array / z.string API that works in Zod 3 and Zod 4.
Why is a field marked optional?
It was missing from at least one object in an array, so the generator assumes it can be absent.
Can I turn off email/URL detection?
Yes — untick “Detect email / URL / UUID / date” to get plain z.string() for every string. It also removes .int() from whole numbers.
How are mixed types handled?
If a field has different types across array items, the schema uses z.union([...]). Where one of the types is null, it is written as a nullable version of the other.
Does it generate a TypeScript type too?
Yes, the last line exports `type Root = z.infer<typeof rootSchema>`, so you need not write the interface separately.