Type-safe schema validation for TypeScript. Zod v4 introduces top-level format functions, z.stringbool(), z.iso. date formats, z.overwrite() transforms, z.file(), z.toJSONSchema(), getter-based recursive types, .meta(), and the unified error function.
| z.object({ ... }) | Define object schemas | | z.string(), z.number() | Primitive types | | z.email(), z.url(), z.uuid() | Top-level string formats (v4) | | z.iso.date(), z.iso.datetime() | ISO date/time formats (v4) | | z.int(), z.float32(), z.int32() | Fixed-width number formats (v4) | | z.templateLiteral([...]) | Template literal type validation (v4) |
| z.enum([...]), z.literal() | Enums and literals | | z.union([...]), z.discriminatedUnion() | Union types | | z.array(), z.tuple() | Array and tuple types | | z.record(), z.map() | Key-value collections | | .optional(), .nullable() | Optional and nullable modifiers | | .default(), .catch() | Default values and fallbacks |