z.infer, z.input & z.output in Zod
From the Zod cheat sheet ยท Type Inference ยท verified Jul 2026
z.infer, z.input & z.output
Use schemas as the single source of truth for runtime and types
typescript
const UserSchema = z.object({
name: z.string(),
age: z.number(),
});
type User = z.infer<typeof UserSchema>;
// { name: string; age: number }๐ก z.infer gives you a TypeScript type for free โ no need to write interfaces twice
โก Use z.input for function parameters and z.output for return types when transforms are involved
๐ Schemas are the single source of truth โ change once, types update everywhere
๐ข Pair Zod with @hookform/resolvers/zod for fully typed React Hook Form validation
infertypesinference