JSON to Zod Schema Converter
Convert JSON into TypeScript interfaces, type aliases or a Zod schema live, with real optional-field detection across arrays.
Result
This page opens the converter with Zod schema preselected as the output format — paste a JSON object or array and it prints a const schema built from z.object(), z.array(), z.union() and primitive calls like z.string() or z.number(), ready to validate that shape of data at runtime.
The same field-comparison engine that powers the interface mode drives this output: a field present in only some items of a pasted array gets .optional() appended, and a field seen as both null and a real value gets .nullable() instead of a raw union, matching how Zod schemas are normally written by hand.
Zod is a separate npm package (npm install zod) that this tool does not install for you — it only generates the schema source, which you paste into a project that already depends on zod. Need plain TypeScript types instead? The same JSON also converts to interfaces or type aliases without leaving this page.