Why Use Zod for Runtime Validation?
TypeScript interfaces are erased at compile time — they cannot catch malformed API responses at runtime. Zod schemas validate data during execution, preventing type assertion failures, null reference errors, and corrupted state.
Smart Type Inference
Unlike basic generators, JSON2X detects semantic string formats and generates specific Zod validators:
- Email addresses →
z.string().email() - URLs →
z.string().url() - UUIDs →
z.string().uuid() - ISO datetime strings →
z.string().datetime() - All other strings →
z.string()
Zero-Duplication Type Safety
Enable "Export inferred type" to get export type MyType = z.infer<typeof mySchema>. This derives a TypeScript type from the Zod schema automatically — no interface declaration needed.