JSON to Zod schema

Paste a JSON payload and get a Zod v4 schema with the inferred TypeScript type, ready for a form resolver or an API route.

json
Zod schemats
The result appears here
Made something you like?Forms that consume this schema

Questions

Which Zod version does the output target?+

Zod v4. With format detection on it uses the top level helpers z.email(), z.url(), z.uuid() and z.iso.datetime(). Turn detection off and the output is plain z.string(), z.number() and z.object(), which also runs on Zod v3.

How are nulls, empty arrays and missing keys handled?+

A null becomes z.null(), because one sample cannot tell you what else the field holds. Inside an array the null merges with its siblings into .nullable(). An empty array becomes z.array(z.unknown()). A key present in some array elements but not others comes out .optional().

Does it accept JavaScript objects, not just strict JSON?+

Yes. Unquoted keys, single quotes, trailing commas, // and /* */ comments, and undefined or NaN as values are all accepted: paste an object straight out of a source file or a console log. Strict JSON is tried first, and the relaxed reading only runs if that fails.

Is my payload uploaded anywhere?+

No. The parser and the code generator run in your browser. Nothing is sent to a server, which is why the tool also works offline once the page is loaded.

Related tools

The tools are free. So is most of the library.

1935 blocks and 989 pieces for shadcn/ui and Tailwind, built on the same tokens these tools write. Install one with a command and the code is yours.

No signup for the tools. MIT for free blocks, commercial licence for Pro.

Markdown version