Zod
Backend & InfraTypeScript-first schema validation with static type inference
Release History
View all versions →v4.5.41 fixThis release includes a bug fix that prevents the default factory from firing during a cycle walk.
v4.5.32 fixesThis release includes bug fixes for toJSONSchema and documentation display issues. It also introduces performance improvements and documentation updates related to z.compile.
v4.5.25 fixesThis release includes several bug fixes related to documentation rendering, blog post display, and ISR on the docs route. It also addresses an issue with vi.spyOn functionality.
v4.5.1This release primarily focuses on CI improvements, gating GitHub releases and JSR publishing to ensure they only occur when the version is live on npm. It also marks the release of version 4.5.1.
v4.5.07 featuresZod 4.5 introduces `z.compile()` for significant parsing performance improvements and adds new validators like `z.creditCard()` and `z.properties()`. It also includes a fast-path validation function `z.validate()` and reduces memory footprint.
v4.4.32 fixesThis release focuses on bug fixes for v4 related to object key handling and includes numerous documentation updates regarding sponsor recognition.
v4.4.21 fix3 featuresThis release focuses on documentation improvements, including fixing heading anchor links and updating guidance, alongside a minor feature enhancement for z.preprocess optionality handling.
v4.4.11 fixThis release (4.4.1) includes a bug fix related to tuple handling in v4 and updates to CI/CD processes, such as gating release publishing on a full test workflow.
v4.4.0Breaking18 fixes5 featuresThis minor release focuses heavily on correctness and soundness fixes, particularly around tuple parsing defaults, object property requirements when using z.undefined(), and stricter string validation rules. Several changes are potentially breaking for code relying on previously ambiguous input handling.
v4.3.62 fixes1 featureThis release introduces generalized numeric key handling and includes minor fixes like correcting a typo and updating robots.txt configuration.
v4.3.51 featureThis release introduces improvements to mini treeshaking and documents the deprecation of the 'message' symbol.
v4.3.4Breaking1 fix3 featuresThis release introduces patternProperties support for looseRecord and improves documentation, while removing the .refine() method from ZodMiniType and dropping ISO time in fromJSONSchema.
v4.3.3Version 4.3.3 release containing a single commit update.
v4.3.2Breaking1 fixVersion 4.3.2 is a maintenance release that removes the Juno integration and refines strictObject validation within intersections.
v4.3.11 featureThis release introduces support for non-overwriting extends when using refinements, improving how configurations or schemas are merged.
v4.3.0Breaking2 fixes12 featuresZod 4.x introduces major features including JSON Schema to Zod conversion, exclusive unions (xor), exact optional properties, and improved intersection logic for strict objects.
v4.2.1Version 4.2.1 is a maintenance release containing a single commit.
v4.2.05 featuresThis release introduces native JSON Schema interoperability with z.fromJSONSchema() and .toJSONSchema(), alongside new schema types like z.xor() and z.looseRecord().
v4.1.138 fixes6 featuresZod v4.1.13 introduces MAC address validation, z.meta/z.describe, and significant performance optimizations for initialization. It also addresses several edge-case bugs in records, tuples, and localization.
v4.1.124 fixes2 featuresVersion 4.1.12 focuses on bug fixes for ZodError flattening, internal error type refactoring, and significant updates to the ecosystem documentation.
v4.1.11Version 4.1.11 is a maintenance release identified by commit 2bed4b3.
v4.1.101 fixVersion 4.1.10 is a patch release that addresses a bug in shape caching.
v4.1.91 fixThis release updates the zshy dependency and publishes zod version 4.1.9.
v4.1.81 fixVersion 4.1.8 is a maintenance release that switches an internal implementation back to using WeakMap.
v4.1.76 fixes5 featuresRelease 4.1.7 focuses on expanding locale support (Lithuanian, Georgian), fixing CIDRv6 validation logic, and ensuring array defaults are shallow-cloned. It also includes significant documentation improvements and ecosystem updates.
Common Errors
ZodError3 reportsA ZodError usually indicates that the data you're trying to parse with a Zod schema doesn't conform to the schema's defined structure or validation rules. To fix this, carefully inspect the Zod schema and the data you're providing to identify any type mismatches, missing required fields, or validation failures. Adjust either the schema to accommodate the data or modify the data to align with the schema's expectations.
PriceOptionsError1 reportThe "PriceOptionsError" in zod usually stems from providing incorrect or missing fields when defining a price option schema, like forgetting the `price` or `label` fields and their respective types, or attempting to set invalid `price_type` if the options don't correspond to their allowed formats. Ensure that price option schema definitions include all required fields with the correct types and values, according to the specific validations set within your codebase or any third-party library constraints relevant to your pricing logic.
PickOnlyUnexpectedKeysDoesCorrectlyError1 reportThis error usually arises when the `pick` method on Zod objects doesn't properly enforce key constraints at compile time, allowing unexpected keys to slip through. To fix it, ensure the `pick` method's return type accurately reflects the picked schema and introduce a type-level check that explicitly verifies the provided keys in the `pick` call are valid for the original Zod object schema, throwing a TypeScript error otherwise. This will re-establish compile-time safety.
AxiosError1 reportThe "AxiosError" in Zod often arises because the type of the data received from the Axios request does not match the schema defined by Zod. To fix this, carefully inspect the structure of the Axios response and adjust your Zod schema to accurately reflect the actual data type and properties. Consider using `.transform()` to map the response data to the expected format before validation if necessary.
Related Backend & Infra Packages
Production-Grade Container Scheduling and Management
Node.js JavaScript runtime ✨🐢🚀✨
Promise based HTTP client for the browser and node.js
A modern runtime for JavaScript and TypeScript.
Deliver web apps with confidence 🚀
Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
Subscribe to Updates
Get notified when new versions are released