- What's Zod?
- A TypeScript-first schema validator. `z.object({...})` defines a runtime-validatable schema that also infers a TypeScript type. Widely used in Next.js/React apps and tRPC.
- How is this different from json-to-typescript-types?
- That tool generates a compile-time type. Zod gives you both the type (via `z.infer`) and a runtime validator that checks incoming JSON matches.
- Does it detect optional fields?
- Fields that appear inconsistently across records become `.optional()`. Always-present fields are required. Small sample sizes can mislead — review.
- What about refinements (min, max, regex)?
- Not auto-inferred — the sample doesn't tell us what constraints matter. Add `.min(1)`, `.max(100)`, `.regex(...)` manually after generation.