JSON to Zod Schema
NewGenerate Zod validation schemas and TypeScript types from JSON data.
Frequently Asked Questions
What is the difference between nullable and the optional-null toggle here?
By default, a sampled null becomes .nullable(). If you turn on Treat null as optional instead of nullable, the same spot becomes .optional() instead.
Why did it infer the array type from only one item?
This generator uses the first non-null array item as the schema sample. It does not build unions from heterogeneous arrays.
How are nested objects emitted?
Nested objects are extracted into separate const ...Schema declarations. The root object stays inline inside the exported root schema.
What does it do with nulls or empty arrays?
null becomes z.unknown().nullable() or z.unknown().optional(), depending on the toggle. Empty arrays become z.array(z.unknown()).
Does it generate both a schema and a TypeScript type?
Yes. It exports the Zod schema constant and an inferred TypeScript type using z.infer<typeof ...>.