JSON to Zod
Writing a Zod schema by hand for an API response you already have is transcription, not design. Paste one or more samples and this infers the field types, marks the keys that are missing from some samples as optional, and emits a schema plus the matching inferred TypeScript type.
target
A single object cannot reveal which keys are optional. Paste an array of several samples to detect them.
how to use it
- 01Paste a JSON object, an array of samples, or NDJSON.
- 02Check the inferred optional and nullable flags.
- 03Copy the generated schema into your project.
questions
- Why do I need more than one sample?
- A single object cannot tell you whether a missing key is optional or simply absent that once. Given several samples, a key present in some and not others is inferred as optional.
- How are nulls handled?
- A field that is null in a sample and typed in another becomes nullable rather than losing its type.