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
Back to the full Zod cheat sheet