>_
Zod

JSON to Zod

Convert sample JSON into a Zod schema plus its inferred TypeScript type. Ready for validating API responses and LLM structured outputs with the Vercel AI SDK or OpenAI SDK.

Runs locally — your input never leaves this page.

How to use

  1. Paste a JSON sample.
  2. Set the schema name — you get NameSchema and type Name = z.infer<typeof NameSchema>.
  3. Keys missing from some array items become .optional(), and mixed nulls become .nullable().
  4. Use the schema with generateObject() in the AI SDK, zodResponseFormat() in the OpenAI SDK, or .parse() anywhere.

FAQ

Does it support Zod 4?

Yes. The output only uses core APIs (z.object, z.array, z.union, .optional(), .nullable()) that are the same in Zod 3 and Zod 4.

Why use Zod for LLM output?

Models occasionally return malformed or unexpected JSON. Validating with Zod gives you a typed object or a clear error you can retry on, instead of a crash somewhere deeper in your app.

Report a bug or suggest a feature →