TS
JSON TO TYPESCRIPT / ZOD

JSON to TypeScript / Zod

Infer TypeScript types and converters or Zod validation code from a JSON sample.

Local processing
Workspace
Inferred from samples, not a complete business contract. Generated code is displayed only, never executed here. Review optional fields, empty arrays and null before using it.
0 characters
Read only
Ready. Enter your content, then choose an action.
◇ Content is processed in this browser onlyInput is not saved automatically
HOW TO USE

How to use

Paste a JSON object, array or primitive and choose TypeScript or Zod. Object arrays are inferred together, so missing fields can become optional. TypeScript includes a Convert helper. The final Zod ResultSchema (prefixed with Ibytes on collision) validates the original JSON value.

Example

In [{"id":1,"name":"Ada"},{"id":2}], name can be inferred as optional while id is numeric.

GOOD TO KNOW

Keep in mind

Generated locally by quicktype in a worker. Limits: 100,000 characters, 40 levels, 20,000 values and 30 seconds per task. Date-like strings remain strings and sample values are not inferred as enums. Use strings for large integers. Install zod in your own project to use Zod output.

Common questions

Why are some inferred types too broad or inaccurate? Samples cannot describe every business rule. Empty arrays have no element information and null does not describe future values. Use representative samples and review constraints.