z.bigint | z.bigint() creates a Zod schema for validating JavaScript bigint values. It supports comparison, sign, and divisibility constraints. |
z.symbol | z.symbol() creates a Zod schema for JavaScript symbols. It validates symbol values at runtime and can also be used alongside symbol-keyed object properties. |
z.undefined | Module |
z.null | z.null() creates a Zod schema that accepts exactly the JavaScript value null. Use z.nullable() or z.nullish() when null should be combined with other accepted values. |
z.void | Module |
z.any | z.any() defines a schema that accepts values of any type and infers any in TypeScript. As an object property, it requires the key unless combined with .optional(). |
z.unknown | z.unknown() defines a schema that accepts any runtime value while inferring TypeScript’s safer unknown type. Use it when input shape is intentionally unrestricted but downstream code must narrow the value before using it. |
z.never | z.never() creates a Zod schema that rejects every input and infers the TypeScript type never. Use it to model an impossible schema branch. |
z.nan | z.nan() creates a schema that accepts JavaScript’s NaN value and rejects all other inputs. Use it when NaN must be validated explicitly rather than treated as an ordinary number. |
z.map | z.map() creates a Zod schema for JavaScript Maps by defining separate schemas for keys and values. It infers the corresponding TypeScript Map type and supports entry-count and readonly constraints. |
z.set | z.set(element) creates a Zod schema for native JavaScript Set values, validating each member with the supplied element schema. Set schemas support cardinality constraints such as nonempty, min, max, and size. |
z.function | Module |
z.promise | Module |
z.nativeEnum | Module |
z.default | .default() supplies a fallback when a schema receives undefined. It returns that fallback immediately and can also generate defaults through a function. |
z.catch | .catch() supplies a fallback when schema validation fails. The fallback can be a fixed value or a function that is rerun for each failure and receives the caught error context. |
z.preprocess | z.preprocess() transforms raw input before passing it to another Zod schema for validation. It is useful for custom normalization or coercion, while straightforward primitive coercion can use Zod's dedicated coercion APIs. |
z.instanceof | z.instanceof(Class) validates that an input is an instance of a specified class. Successful parsing preserves the original object, including its prototype and identity. |
z.pipe | z.pipe() composes schemas into a sequential pipeline. It is especially useful for validating data before a transform and validating or processing the transformed result. |
z.transform | z.transform() creates a standalone, unidirectional schema that accepts any input and maps it to a new output. Use it with z.pipe() or .transform() when input validation should precede the conversion. |
.min | Module |
.max | .max() adds an inclusive upper bound to a Zod schema. Its meaning depends on the schema: string length, array item count, file size, or a comparable maximum for dates and bigints. |
.length | .length(n) requires a string or array to have exactly n units according to Zod’s counting rules. Strings are measured in Unicode code points; arrays are measured by item count. |
.email | z.email() creates a schema for validating email addresses. It uses a comparatively strict default pattern and accepts a custom pattern regular expression for alternative rules. |
.url | z.url() validates WHATWG-compatible URL strings. Optional protocol and hostname regular expressions let you narrow the accepted URLs. |
.uuid | z.uuid() creates a Zod schema for validating RFC 9562/4122-compliant UUID strings. It can restrict validation to a specified UUID version, while z.guid() handles less strict UUID-like identifiers. |
.cuid | Module |
.cuid2 | Module |
.ulid | Module |
.regex | Module |
.startsWith | Module |
.endsWith | Module |
.includes | Module |
.trim | z.string().trim() creates a string schema that removes surrounding whitespace from parsed values. It is a built-in string transformation that can be chained with other string checks and transforms. |
.toLowerCase | .toLowerCase() defines a Zod string schema that converts parsed strings to lowercase. It is a chainable string transformation. |
.toUpperCase | .toUpperCase() transforms parsed strings to uppercase. It takes no arguments and can be chained with other string transformations such as .trim(). |
.datetime | z.iso.datetime() validates strings against a strict subset of ISO 8601. Timezone offsets are rejected by default and can be enabled with { offset: true }. |
.ip | Zod provides separate schemas for IPv4 and IPv6 addresses. Use z.union() to accept either format. |
.emoji | z.emoji() validates a single emoji character in current Zod. It accepts complete emoji, including keycap sequences, while rejecting component-only strings such as 123. |
.nanoid | z.nanoid() creates a Zod schema for validating Nano ID strings. Use it wherever a schema is needed, including object fields and collections. |
.base64 | Module |
.gt | Module |
.gte | .gte(value) adds an inclusive minimum constraint to a Zod number schema. Inputs below the supplied threshold fail validation, while the threshold and larger values are accepted. |
.lt | z.number().lt(value) validates finite numbers that are strictly less than value. It adds an exclusive upper bound to a Zod number schema. |
.lte | Module |
.int | z.int() defines a Zod schema for safe JavaScript integers. It accepts integer numbers within the safe range and rejects fractional, non-number, or unsafe values. |
.positive | Module |
.negative | Module |
.nonnegative | Module |
.multipleOf | .multipleOf(value) constrains a Zod number to values that are multiples of value. Zod documents .step(value) as an alias. |
.finite | Module |
.safe | .safeParse validates input and returns a result object instead of throwing on validation failure. Check success to access either parsed data or a ZodError. |
.parse | .parse validates an unknown value against a Zod schema. It returns a strongly typed deep clone on success and throws a ZodError on failure. |
.safeParse | Zod's safeParse method validates input without throwing for validation failures. It returns a discriminated result containing either parsed data or a ZodError. |
.parseAsync | Module |
.safeParseAsync | Module |
.partial | .partial() derives a Zod object schema with optional properties. Use it without arguments for all fields, or provide a mask to make only selected fields optional. |
.deepPartial | z.deepPartial() recursively makes properties optional throughout a Zod schema. Unlike .partial(), it can traverse nested structures such as objects, arrays, tuples, unions, records, and wrappers. |
.pick | .pick derives a new Zod object schema containing only selected properties from an existing object schema. Provide a mask with the keys to retain set to true. |
.omit | .omit() derives a Zod object schema without selected keys. Pass a mask with the keys to remove set to true. |
.extend | .extend() creates a new object schema by adding fields to an existing object schema. Duplicate keys are overwritten by the supplied shape. |
.merge | Module |
.passthrough | Module |
.strict | Module |
.strip | Module |
.shape | .shape exposes the individual field schemas inside a Zod object schema. Use it to retrieve a validator for a specific key, such as Dog.shape.name. |
.keyof | Module |
.array | .array() turns an existing Zod schema into an array schema, so each item is validated against that schema. Use array length methods such as .min(), .max(), .length(), and .nonempty() for collection constraints. |
.or | Module |
.and | Module |
.nullish | .nullish() makes a Zod schema accept its normal values plus null and undefined. It combines nullable and optional behavior. |
.describe | .describe() registers a schema description in Zod's global registry and returns a new schema instance. Zod recommends .meta() for new metadata because it supports the broader metadata API. |
.refine | .refine() adds custom validation to any Zod schema. Its predicate passes on truthy results and reports a custom issue on falsy results, with optional error and continuation settings. |
.superRefine | .superRefine() adds custom validation logic to a schema and can report multiple issues. It also supports Zod's internal issue types, unlike the single custom issue produced by .refine(). |
.readonly | .readonly() marks a schema’s inferred output as readonly and freezes the parsed result at runtime. It supports objects, arrays, tuples, Set, and Map. |
z.file | z.file() creates a schema for validating File instances. Add byte-size limits with .min() and .max(), and restrict accepted content types with .mime(). |
z.stringbool | z.stringbool() parses supported boolean-like strings into plain booleans. It is useful for text-based inputs such as environment variables and can encode booleans back to strings. |
z.iso.datetime | z.iso.datetime() validates strings against a strict subset of ISO 8601. By default it accepts UTC-style datetimes, rejects timezone offsets and local datetimes, and can allow offsets with { offset: true }. |
z.iso.date | z.iso.date() validates strings in the YYYY-MM-DD format and rejects malformed or impossible calendar dates. Use z.date() for JavaScript Date instances. |
z.templateLiteral | z.templateLiteral creates a Zod schema for strings formed by concatenating literal text and compatible schemas. It validates the complete assembled value and infers a corresponding TypeScript template-literal type. |