Collection Schemas in Zod
From the Zod cheat sheet ยท Arrays, Tuples, Sets & Maps ยท verified Jul 2026
Collection Schemas
Define arrays, tuples, sets, maps, and records
typescript
// Array
z.array(z.string());
z.string().array();
// Tuple (fixed length, mixed types)
z.tuple([z.string(), z.number(), z.boolean()]);
// Record (key-value object)
z.record(z.string(), z.number());๐ก z.array(z.X) and z.X.array() are equivalent โ pick whichever reads better
โก Use z.tuple() for fixed-length arrays with positional types like coordinates
๐ z.record() validates plain objects with dynamic keys โ different from z.map()
๐ข z.set() and z.map() work on actual Set/Map instances, not arrays/objects
arraytuplesetmaprecord