jsontoolskit.org
JSON and JSON Schema utilities, in the browser
Say hi →

JSON → Zod

Zod schemas · optional TS type alongside · strict-by-default

Paste a JSON sample, get a Zod schema. Toggle also infer TS type for type X = z.infer<typeof XSchema>. Toggle strict objects to disallow unknown keys.

Paste JSON.

How to generate Zod

  1. Paste your JSON.
  2. Toggle:
    • Also infer TS type — adds type X = z.infer<typeof XSchema> lines.
    • Strict objects — adds .strict() to disallow unknown keys.
    • Optional vs nullable — distinguish from samples with multiple inputs.
  3. Output appears below. Copy or Download as .ts.

FAQ

What about z.coerce?

The tool generates plain z.string() / z.number(). If you need to accept stringified numbers (e.g. from URL params), swap in z.coerce.* after generation.

How do I get optional fields?

Provide a second sample with the optional field missing — the schema becomes field: z.string().optional().

Will it work offline?

Yes — inference is local.