JSON to Zod Converter
Generate a Zod schema that validates your JSON shape.
JSON
Zod schema
About the JSON to Zod converter
A TypeScript interface disappears at runtime, so it cannot tell you that an API returned something unexpected — it only promises that it will not. A Zod schema checks the data as it arrives and gives you the type for free through `z.infer`.
Paste a response and get both: a schema you can parse with, and a type derived from it that cannot drift out of sync.
Why validate at the boundary
Anywhere data enters your program from outside — an HTTP response, a config file, `localStorage` — a declared type is an assumption rather than a fact. Parsing with a schema turns a confusing failure deep in your code into a clear one at the edge.
Because the type comes from `z.infer`, there is only one definition to maintain instead of a type and a validator that can disagree.
What to tighten by hand
The generated schema is structural: it knows a field is a string, not that it is an email or a UUID. Adding `.email()`, `.uuid()`, `.min()` and `.optional()` is where the real value is, and only you know which apply.
Integers are emitted as `z.number().int()` where the sample had no fractional part — check that this is genuinely a constraint and not a coincidence of the sample.
Types come from one sample
Everything here is inferred from the JSON you paste. A field that happens to be absent from your example will be absent from the output, and a field that is null in the sample cannot be typed at all — only marked as nullable.
Paste the richest response you have, then review the optional and nullable fields by hand. Treat the result as a fast first draft rather than a schema.
Frequently asked questions
Zod 3 or Zod 4?
The generated schema uses the core API that is unchanged between them, so it works with either.
Why is my null field typed so loosely?
Because a single null tells you nothing about what the field looks like when it is populated. It is marked nullable or optional so the code compiles, and it is the first thing worth correcting by hand.
Is my JSON uploaded?
No. The conversion runs in your browser, which matters when the sample you are pasting is a real API response with real customer data in it.