unstale

npm / zod

zod

What changed in zod 4, from its official release notes, upgrade guides and advisories. Sources checked 2026-10-17.

41 breaking2 security3 deprecations65 new APIs and options12 performance28 behavior and defaults65 fixes and other

zod 4216 changes

Breaking changes 41

  • The standalone z.properties() schema is removed; the .properties() method form remains available.

    4.6.3release notes

  • Now enforces minProperties, maxProperties, uniqueItems, contains, minContains, and maxContains instead of ignoring them.

    4.6.0release notes

  • Error maps now run when result.error is first read, so configuration changes between parsing and reading affect the message.

    4.6.0release notes

  • Rejects component-only strings and now requires at least one pictograph, regional indicator, or keycap.

    4.6.0release notes

  • Embedding z.email no longer applies the email segment's no-consecutive-dots rule to the rest of the template string.

    4.6.0release notes

  • Folds chained checks as a conjunction so tighter bounds are preserved and check order no longer changes emitted JSON Schema.

    4.6.0release notes

  • Empty enums and literals now match nothing.

    4.5.0release notes

  • Imported tuples are open-ended by default.

    4.5.0release notes

  • String exact-length validation now counts Unicode code points instead of UTF-16 code units.

    4.5.0release notes

  • String maximum-length validation now counts Unicode code points instead of UTF-16 code units.

    4.5.0release notes

  • String minimum-length validation now counts Unicode code points instead of UTF-16 code units.

    4.5.0release notes

  • Parsed objects consistently strip __proto__ keys, improving protection against prototype pollution.

    4.5.0release notes

  • Object and record parsers strip __proto__ keys and protect formatters and JSON Schema converters from prototype pollution paths.

    4.5.0release notes

  • Record key schemas now govern only matching keys, and pattern-keyed record intersections no longer reject unrelated object keys.

    4.5.0release notes

  • Strict object parsing reports an own __proto__ key instead of treating it as inherited.

    4.5.0release notes

  • Measures string length in Unicode code points.

    4.5.0release notes

  • Zod Mini requires registering a memoizer before defining schemas to support cyclical inputs.

    4.5.0release notes

  • Requires seconds when a datetime includes Z or an offset.

    4.5.0release notes

  • Enforces RFC 1035 host length limits, matching z.hostname().

    4.5.0release notes

  • Validates IPv6 strings directly against the address alphabet, rejecting values previously accepted through URL parsing.

    4.5.0release notes

  • RFC 3339 datetime validation now requires seconds unless local mode is enabled.

    4.5.0release notes

  • Rejects ULIDs whose first character exceeds 7 because the encoded timestamp would overflow 48 bits.

    4.5.0release notes

  • Base64 validation rejects whitespace to prevent an atob bypass.

    4.4.0release notes

  • The ecosystem ESLint plugin is now named eslint-plugin-zod instead of eslint-plugin-zod-x.

    4.4.0release notes

  • Non-JSON-like inputs such as cyclic objects and BigInt are now rejected or normalized more consistently.

    4.4.0release notes

  • The .merge() method now throws when the receiver has refinements, avoiding ambiguous refinement behavior.

    4.4.0release notes

  • Merging a schema with receiver refinements now throws, while refinements from the second schema are preserved.

    4.4.0release notes

  • Object catchall paths now skip __proto__ keys to harden against prototype pollution.

    4.4.0release notes

  • Object catchall parsing skips the __proto__ key.

    4.4.0release notes

  • Tuple defaults now materialize in parsed output, while absent optional tails remain absent and explicit undefined values are preserved.

    4.4.0release notes

  • Base64 validation now rejects whitespace instead of accepting inputs after atob-style whitespace stripping.

    4.4.0release notes

  • CUID validation has been tightened, changing which inputs are accepted.

    4.4.0release notes

  • Malformed HTTP(S) URLs missing a slash after the protocol are now rejected instead of being accepted after URL normalization.

    4.4.0release notes

  • Object properties using z.undefined() are now required to be present; use .optional() when the key may be absent.

    4.4.0release notes

  • ISO time handling was dropped from fromJSONSchema.

    4.3.4release notes

  • ZodMiniType no longer provides the refine method.

    4.3.4release notes

  • Tightens the E.164 regex to require a non-zero leading digit and 7–15 total digits.

    4.3.0release notes

  • Throws when overwriting existing properties on object schemas with refinements.

    4.3.0release notes

  • Throws when called on object schemas containing refinements instead of silently dropping those refinements.

    4.3.0release notes

  • Throws when called on object schemas containing refinements instead of silently dropping those refinements.

    4.3.0release notes

  • Intersections reject keys only when unrecognized by both sides, allowing keys recognized by either side to pass validation.

    4.3.0release notes

Security 2

  • Uses linear runtime character-set validation with code-enforced length and padding, preventing regex stack overflow on huge inputs.

    4.6.0release notes

  • Reserved-key handling is hardened across Zod 4 schemas.

    4.5.0release notes

Deprecations 3

  • The cuid regex is tightened and CUID v1 is deprecated.

    4.4.0release notes

  • CUID v1 is now deprecated.

    4.4.0release notes

  • The message API is deprecated; developers should consult the migration guide for the replacement.

    4.3.5release notes

New APIs and options 65

  • Adds z.currencyCode() using a vendored ISO 4217 list refreshed weekly by CI.

    4.6.4release notesrelease notes

  • Adds the Tajik locale for localized Zod messages.

    4.6.1release notes

  • Adds asynchronous boolean validation for schemas with async refinements.

    4.6.0release notes

  • Adds IBAN string validation in electronic format with an ISO 7064 MOD 97-10 checksum.

    4.6.0release notes

  • Adds a properties method for validating properties on instances without replacing the instance.

    4.6.0release notes

  • Adds in-place validation of selected object properties while preserving the input instance and prototype.

    4.6.0release notes

  • Allows extra arguments to be passed to apply().

    4.5.0release notes

  • Bun can preload zod/compile through the preload configuration.

    4.5.0release notes

  • Adds partial schemas that allow omitted keys but reject explicitly provided undefined values.

    4.5.0release notes

  • Supports format: "hostname" when converting JSON Schema.

    4.5.0release notes

  • Adds Hindi, Kannada, Slovak, Bengali, Turkmen, Norwegian Nynorsk, Central Kurdish, Brazilian Portuguese, Greek, and Croatian locale support.

    4.5.0release notes

  • Node.js can preload zod/compile before application modules define schemas.

    4.5.0release notes

  • Nub can preload zod/compile through the preload configuration.

    4.5.0release notes

  • Allows tuple items to become optional with .partial().

    4.5.0release notes

  • Accepts a function for unrepresentable values and runs override before the unrepresentable error.

    4.5.0release notes

  • Adds boolean validation without constructing a result or ZodError, with type-guard narrowing and short-circuiting.

    4.5.0release notesrelease notes

  • Pre-compiles any Zod schema for substantially faster parsing while preserving normal schema behavior and error reporting.

    4.5.0release notes

  • Adds ahead-of-time schema compilation.

    4.5.0release notes

  • Adds string validation for 12–19 digit credit-card values with optional separators and a valid Luhn checksum.

    4.5.0release notes

  • Adds credit-card string validation.

    4.5.0release notes

  • Restores deep partial schema construction as a top-level functional API.

    4.5.0release notes

  • Adds deep partial schemas and runtime z.input and z.output helpers.

    4.5.0release notes

  • Adds extraction of a discriminated-union member by discriminator value.

    4.5.0release notes

  • Adds a helper for retrieving a discriminated-union option.

    4.5.0release notes

  • Results from .implement() expose the underlying function schema.

    4.5.0release notes

  • Adds projection of a schema onto its input side for independently validating codec inputs.

    4.5.0release notes

  • Adds synchronous and asynchronous boolean validation helpers.

    4.5.0release notes

  • Accepts a custom length for generated or validated NanoIDs.

    4.5.0release notes

  • Object shapes can declare symbol keys, which are tracked by TypeScript and validated as required keys.

    4.5.0release notes

  • Adds projection of a schema onto its output side for independently validating codec outputs.

    4.5.0release notes

  • Adds a multi-property counterpart to z.property() for checking several properties together.

    4.5.0release notes

  • Exposes stringbool truthy, falsy, and case settings through _zod.bag.

    4.5.0release notes

  • Adds a utility for defining a Zod schema that agrees exactly with a static TypeScript type.

    4.5.0release notes

  • Adds the z.toZod helper.

    4.5.0release notes

  • Adds asynchronous boolean validation for schemas with async refinements.

    4.5.0release notes

  • Importing zod/compile automatically compiles schemas when they are first used to parse data.

    4.5.0release notes

  • Adds .exactPartial() to ZodObject.

    4.5.0release notes

  • Croatian locale support was added.

    4.4.0release notes

  • Greek locale support was added.

    4.4.0release notes

  • The JSONType export was added.

    4.4.0release notes

  • A Romanian locale is added for Zod error messages.

    4.4.0release notes

  • Romanian locale support was added.

    4.4.0release notes

  • The when option was added to conditionally run .superRefine() checks.

    4.4.0release notes

  • Transform callbacks can now report validation issues through ctx.addIssue().

    4.4.0release notes

  • Uzbek map support was added to locale support.

    4.4.0release notes

  • Codec inversion was added, allowing a codec with reversed input and output directions.

    4.4.0release notes

  • looseRecord now supports patternProperties.

    4.3.4release notes

  • Adds a utility method for applying arbitrary transformations to a schema.

    4.3.0release notes

  • Adds the Armenian locale for localized Zod error messages.

    4.3.0release notes

  • Accepts a second argument controlling whether branding applies to input, output, or both.

    4.3.0release notes

  • Adds a wrapper that permits omitted properties but rejects explicit undefined values.

    4.3.0release notes

  • Adds an extension method that preserves refinements while statically preventing incompatible property overwrites.

    4.3.0release notes

  • Adds the Uzbek locale for localized Zod error messages.

    4.3.0release notes

  • Adds a more readable alias for check to support explicit schema composition.

    4.3.0release notes

  • Converts JSON Schema definitions directly into Zod schemas, supporting several JSON Schema drafts and OpenAPI 3.0.

    4.3.0release notes

  • Adds record validation that validates matching keys while passing through non-matching keys unchanged.

    4.3.0release notes

  • Adds z.fromJSONSchema() to create a Zod schema from a JSON Schema definition.

    4.2.0release notes

  • Adds z.looseRecord() to allow additional properties beyond those defined.

    4.2.0release notes

  • Zod implements Standard JSON Schema interoperability.

    4.2.0release notes

  • Adds a .toJSONSchema() method for converting Zod schemas to JSON Schema.

    4.2.0release notes

  • Adds an exclusive union that requires exactly one option to match and emits oneOf in JSON Schema.

    4.2.0release notesrelease notes

  • Adds z.describe for describing schemas.

    4.1.13release notes

  • MAC address validation was added to Zod 4 and Zod Mini.

    4.1.13release notes

  • Adds z.meta for attaching metadata to schemas.

    4.1.13release notes

  • Adds a transform that converts strings into URL-friendly slugs.

    4.1.13release notesrelease notes

Performance 12

  • Size bounds are checked before parsing elements, preventing unnecessary element parsing.

    4.6.6release notes

  • Invalid URL rejection is about 50x faster with fewer allocations during validation.

    4.6.4release notes

  • The CommonJS build uses plain properties and frozen exports, making namespace calls such as z.validate faster under require.

    4.6.0release notes

  • Removes lookaheads from the email pattern while preserving validation behavior, making valid-address validation roughly twice as fast.

    4.6.0release notes

  • The emoji regex no longer uses exponential backtracking.

    4.5.0release notes

  • Failure-path safeParse no longer captures an error stack trace, making invalid parses substantially faster.

    4.5.0release notes

  • Schema instances retain substantially less heap memory through lazy method memoization.

    4.5.0release notes

  • Three dead declarations can now be removed by esbuild tree shaking.

    4.5.0release notes

  • Avoids exponential regex backtracking when emoji validation fails.

    4.5.0release notes

  • ZodError construction is deferred, reducing unnecessary error-construction work.

    4.5.0release notes

  • Classic builder methods are lazily bound through a shared prototype, reducing per-schema method allocation overhead.

    4.4.0release notes

  • Top-level factory calls are marked pure so bundlers can eliminate unused code more effectively.

    4.4.0release notes

Behavior and default changes 28

  • Record input and output types are declared as members rather than base type arguments.

    4.6.6release notes

  • The .properties() shape is keyed off the instance type.

    4.6.5release notes

  • Zod Classic metadata members are prototype getters that materialize as own properties only after first read.

    4.6.0release notes

  • Recursive schemas now support cyclical input data and preserve cyclic references in parsed results.

    4.5.0release notes

  • Emits a root $ref when the root schema has an id.

    4.5.0release notes

  • Compacts simple anyOf unions into a JSON Schema type array.

    4.5.0release notes

  • Unrecognized-key issues no longer abort their schema, allowing strict-object extra-key and invalid-value issues to be reported together.

    4.5.0release notes

  • Dynamic .catch() is allowed when unrepresentable is set to any.

    4.5.0release notes

  • Falls back instead of throwing when compilation cannot be used.

    4.5.0release notes

  • Supports declared symbol keys in object schemas.

    4.5.0release notes

  • Parses input containing reference cycles.

    4.5.0release notes

  • Generates a JSON Schema pattern allowing at least N leading characters for includes with a position.

    4.5.0release notes

  • Discriminated union option typing is tightened.

    4.4.2release notes

  • Optionality is deferred to the inner schema.

    4.4.2release notes

  • Invalid discriminated union errors now include discriminator options and improved messages.

    4.4.0release notes

  • Global configuration is now shared through globalThis across mixed CommonJS and ESM module instances.

    4.4.0release notes

  • globalConfig is shared across module systems through globalThis.

    4.4.0release notes

  • Jitless mode now avoids eval probing when enabled before first access.

    4.4.0release notes

  • Object and tuple optionality handling is aligned, including optionality propagation behavior.

    4.4.0release notes

  • Object constructors and shape operations apply writable types for consistent shape display and inference.

    4.4.0release notes

  • Key schema transforms are now applied when parsing records.

    4.4.0release notes

  • Generated stub package manifests now declare sideEffects: false, improving bundler tree-shaking.

    4.4.0release notes

  • Record key refinement failures now surface as structured invalid_key issues.

    4.4.0release notes

  • Record schemas now apply transforms to record keys before producing parsed output.

    4.4.0release notes

  • Numeric key handling was generalized, potentially affecting schemas or APIs that process numeric keys.

    4.3.6release notes

  • strictObject is less restrictive when used inside an intersection.

    4.3.2release notes

  • Removes registry-level enforcement that metadata IDs must be unique.

    4.3.0release notes

  • z.record now supports number literal keys and TypeScript enum keys.

    4.1.13release notes

Fixes and other changes 65

  • Preserves undefined prefault outputs and object keys, preventing those values or keys from being lost.

    4.6.2release notes

  • Unique tags are preserved when discriminators have defaults.

    4.6.1release notes

  • Recursive object index inference is deferred.

    4.6.1release notes

  • Cycle walking no longer fires a default factory unexpectedly.

    4.5.4release notes

  • Record numeric keys are emitted as strings in JSON Schema output.

    4.5.3release notes

  • Prototype method getters now answer a bare call, allowing vi.spyOn to work.

    4.5.2release notes

  • Stops resurrecting issues that an optional schema already resolved.

    4.5.0release notes

  • Builds catch context from the input that failed.

    4.5.0release notes

  • The cidrv6 JSON Schema pattern now matches runtime validation.

    4.5.0release notes

  • Constrains emitted JSON Schema tuple length.

    4.5.0release notes

  • The default English locale is preserved in tree-shaken bundles.

    4.5.0release notes

  • Error-tree walkers use own-property semantics consistently.

    4.5.0release notes

  • formatError correctly handles inherited-name path elements.

    4.5.0release notes

  • Respects additionalProperties:false together with patternProperties.

    4.5.0release notes

  • propertyNames now composes with the other object keywords.

    4.5.0release notes

  • Correctly escapes and unescapes reserved JSON Pointer characters in JSON Schema references.

    4.5.0release notes

  • JSON Schema conversion keeps __proto__ keys as own properties.

    4.5.0release notes

  • Corrects date/time format keywords in both JSON Schema directions.

    4.5.0release notes

  • The documented keyof() ZodEnum type uses the Zod 4 form.

    4.5.0release notes

  • Allows bundlers to tree-shake locales out of the default import.

    4.5.0release notes

  • Accepts exact decimal multiples that were previously rejected.

    4.5.0release notes

  • Declared __proto__ keys are written as own properties.

    4.5.0release notes

  • Record input keys become optional when the value schema can supply them.

    4.5.0release notes

  • No longer throws when bigint multipleOf is configured as 0n.

    4.5.0release notes

  • treeifyError correctly handles inherited-name path elements.

    4.5.0release notes

  • Record keys are re-checked after the key schema runs, preventing transformed keys from bypassing validation.

    4.5.0release notes

  • Catch handling for absent object keys was restored.

    4.4.3release notes

  • Preprocess handling for absent object keys was restored.

    4.4.3release notes

  • Opt-in and fallback behavior was generalized to transform.

    4.4.3release notes

  • Tuple holes are rejected before required defaults are applied, correcting validation behavior.

    4.4.1release notes

  • Map and Set defaults are cloned during parsing, preventing shared state across parses.

    4.4.0release notes

  • Encoding now works when the discriminator uses a codec.

    4.4.0release notes

  • French issue origin translations were added or updated.

    4.4.0release notes

  • Schema generation applies metadata more consistently across several JSON Schema constructs.

    4.4.0release notes

  • The Georgian translation for string validation was corrected.

    4.4.0release notes

  • Italian validation messages were updated.

    4.4.0release notes

  • The allowsEval probe now honors the jitless configuration.

    4.4.0release notes

  • Length validation logic is corrected so schemas validate lengths as intended.

    4.4.0release notes

  • Map defaults are now cloned instead of shared across parses.

    4.4.0release notes

  • Floating-point multipleOf validation is now more accurate for decimal and exponent edge cases.

    4.4.0release notes

  • Parse functions preserve context immutability.

    4.4.0release notes

  • Falsy prefault values are emitted correctly in generated JSON Schema.

    4.4.0release notes

  • Set defaults are now cloned instead of shared across parses.

    4.4.0release notes

  • Floating-point step validation is now more accurate for decimal and exponent edge cases.

    4.4.0release notes

  • Empty unions are constructed instead of causing a crash.

    4.4.0release notes

  • Nested union paths are now preserved correctly in formatted errors.

    4.4.0release notes

  • Non-enumerable properties are now skipped more consistently during record validation.

    4.4.0release notes

  • The v3-style single-argument z.record(valueType) form works again.

    4.4.0release notes

  • Redundant id fields are removed from $defs entries to preserve correct reference resolution in older JSON Schema dialects.

    4.4.0release notes

  • Nested union paths are now preserved correctly in treeified errors.

    4.4.0release notes

  • Empty unions now construct successfully and fail at parse time instead of crashing during construction.

    4.4.0release notes

  • Empty xor schemas now construct successfully and fail at parse time instead of crashing during construction.

    4.4.0release notes

  • extend now allows non-overwriting extensions on schemas with refinements.

    4.3.1release notes

  • Fixes inferred types so implementAsync always returns a promise.

    4.3.0release notes

  • Updates parameter typing to accept string or $ZodCheckIncludesParams.

    4.3.0release notes

  • Converts Date instances to numbers for maximum checks.

    4.3.0release notes

  • Converts Date instances to numbers for minimum checks.

    4.3.0release notes

  • Fixes JSON Schema generation for time values with minute precision.

    4.3.0release notes

  • Improves handling of numeric keys in record schemas.

    4.3.0release notes

  • The dual package hazard affecting globalRegistry was fixed for projects using multiple package entry points.

    4.1.13release notes

  • Partial record handling was fixed for schemas using partial record behavior.

    4.1.13release notes

  • Recursive tuples no longer trigger infinite recursion during processing.

    4.1.13release notes

  • Regexes are reflected correctly in validation errors, making reported patterns accurate to developers.

    4.1.13release notes

  • The inferred type for z.promise() was corrected, improving TypeScript accuracy for promise schemas.

    4.1.13release notes

  • Discriminated unions now use oneOf in generated JSON Schema.

    4.1.13release notes