JSON to Zod Schema Converter
Generate a Zod schema from sample JSON. Detects emails, URLs and ISO dates, marks fields missing from some array items as optional, and adds an inferred TypeScript type. Everything runs locally in your browser; nothing is uploaded.
Paste a sample API response. The tool writes a z.object() schema with detected types and an exported TypeScript type via z.infer. Review optional and nullable fields before using it.
Sample JSON
Zod schema (TypeScript)
Output appears here.Learn more
A starting point, not a spec
A schema from one sample reflects only that sample. Fields that were null may also hold strings, and numbers may be floats elsewhere. Treat the output as a draft and tighten it against your API docs.
Why validate at runtime
TypeScript types disappear at runtime, so a malformed API response passes silently. A Zod schema checks the data at the boundary and gives you a typed result.
Frequently asked questions
How are optional fields decided?
If a key is missing from some objects in an array, it is marked .optional(). One sample cannot reveal optional fields otherwise.
Are formats detected?
Emails, http(s) URLs and ISO date-times get .email(), .url() and .datetime().
Which Zod version does the output target?
The output uses z.object, z.string, z.number and similar functions that exist in both Zod 3 and Zod 4.