Generate Zod Schemas from Real Data
Zod is the most popular TypeScript-first validation library. You describe the shape of your data once and get both runtime validation and a static type through z.infer. Writing that schema by hand for a large API response is slow and easy to get wrong. This tool reads a JSON sample and writes the schema for you.
What the Generator Infers
- Primitives: strings, booleans, and numbers, including
.int()when every sample is a whole number. - Nullable and optional:
nullvalues add.nullable(), and keys missing from some array items add.optional(). - Arrays of objects: all items are merged into one element schema instead of trusting only the first item.
- Mixed types: a field that is sometimes a string and sometimes a number becomes
z.union([...]). - Awkward keys: keys such as
"first-name"are quoted so the output always compiles.
Refine After Generating
A sample cannot tell the generator what a value means. After pasting the schema into your code, tighten strings that have a known format with .email(), .url(), .uuid() or .datetime(), and replace fixed sets of strings with z.enum([...]).
Related Tools
Prefer plain types? Use JSON to TypeScript. If your sample will not parse, fix it first with the JSON Fixer or check it in the JSON Validator. Everything runs locally in your browser.

