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