chore(deps): update dependency zod to v4 (src-dir)
This PR contains the following updates:
| Package | Change | Age | Confidence |
|---|---|---|---|
| zod (source) | ^3.25.67 -> ^4.1.13 |
Release Notes
colinhacks/zod (zod)
v4.1.13
v4.1.12
Commits:
0b109c3docs(ecosystem): add bupkis to the ecosystem section (#5237)d22ec0ddocs(ecosystem): add upfetch (#5238)c56a4f6docs(ecosystem): addeslint-plugin-zod-x(#5261)a0abcc0docs(metadata.mdx): fix a mistake in an example output (#5248)62bf4e4fix(ZodError): prevent flatten() from crashing on 'toString' key (#5266)02a5840refac(errors): Unify code structure and improve types (#5278)4b1922adocs(content/v4/index): fix zod version (#5289)3fcb20fAdd frrm to ecosystem (#5292)fda4c7cMake docs work without tokenaf44738Fix lint77c3c9fExport bg.ts3b94610v4.1.12
v4.1.11
Commits:
2bed4b34.1.11
v4.1.10
Commits:
v4.1.9
Commits:
v4.1.8
Commits:
v4.1.7
Commits:
0cca351Fix variable name inconsistency in coercion documentation (#5188)aa78c27Add copy/edit buttons76452d4Update button txt937f73cFix tsconfig issue in bench976b436v4.1.6 (#5222)4309c61Fix cidrv6 validation - cidrv6 should reject invalid strings with multiple slashes (#5196)ef95a73feat(locales): Add Lithuanian (lt) locale (#5210)3803f3fdocs: update wrong contents in codeblocks inapi.mdx(#5209)8a47d5cdocs: update coerce example inapi.mdx(#5207)e87db13feat(locales): Add Georgian (ka) locale (#5203)c54b123docs: adds@traversable/zodand@traversable/zod-testto v4 ecosystem (#5194)c27a294Fix two tiny grammatical errors in the docs. (#5193)23a2d66docs: fix broken links in async refinements and transforms references (#5190)845a230fix(locales): Add type name translations to Spanish locale (#5187)27f13d6Improve regex precision and eliminate duplicates in regexes.ts (#5181)a8a52b3fix(v4): fix Khmer and Ukrainian locales (#5177)887e37cUpdate slugse1f1948fix(v4): ensure array defaults are shallow-cloned (#5173)9f65038docs(ecosystem): add DRZL; fix Prisma Zod Generator placement (#5215)aa6f0f0More fixes (#5223)aab33564.1.7
v4.1.6
v4.1.5
Commits:
v4.1.4
Commits:
3291c61fix(v4): toJSONSchema - wrong tuple withnulloutput when targetingopenapi-3.0(#5156)23f41c7test(v4): toJSONSchema - usevalidateOpenAPI30Schemain all relevant scenarios (#5163)0a09fd2Update installation instructions4ea5fec4.1.4
v4.1.3
Commits:
98ff675Drop stringToBooleana410616Fix typo0cf4589fix(v4): toJSONSchema - add missing oneOf inside items in tuple conversion (#5146)8bf0c16fix(v4): toJSONSchema tuple path handling for draft-7 with metadata IDs (#5152)5c5fa90fix(v4): toJSONSchema - wrong record output when targetingopenapi-3.0(#5141)87b97ccdocs(codecs): update example to use payloadSchema (#5150)309f358fix(v4): toJSONSchema - output numbers with exclusive range correctly when targetingopenapi-3.0(#5139)1e71ca9docs: fix refine fn to encode works properly (#5148)a85ec3cfix(docs): correct example to useLooseDoginstead ofDog(#5136)3e982744.1.3
v4.1.2
Commits:
e45e61bImprove codec docs25a4c37fix(v4): toJSONSchema - wrong record tuple output when targetingopenapi-3.0(#5145)0fa4f46Use method form in codecs.mdx940383dUpdate JSON codec and docs3009fa84.1.2
v4.1.1
Commits:
648eb43Remove codecs from sidebare7e39a99Improve codec docse5085beAdd images028b289Add methods10cc9944.1.1
v4.1.0
The first minor version since the introduction of Zod 4 back in May. This version contains a number of features that barely missed the cut for the 4.0 release. With Zod 4 stable and widely adopted, there's more time to resume feature development.
Codecs
This is the flagship feature of this release. Codecs are a new API & schema type that encapsulates a bi-directional transformation. It's a huge missing piece in Zod that's finally filled, and it unlocks some totally new ways to use Zod.
const stringToDate = z.codec(
z.iso.datetime(), // input schema: ISO date string
z.date(), // output schema: Date object
{
decode: (isoString) => new Date(isoString),
encode: (date) => date.toISOString(),
}
);
New top-level functions are added for processing inputs in the forward direction ("decoding") and backward direction ("encoding").
stringToDate.decode("2025-08-21T20:59:45.500Z")
// => Date
stringToDate.encode(new Date())
// => "2025-08-21T20:59:45.500Z"
Note — For bundle size reasons, these new methods have not added to Zod Mini schemas. Instead, this functionality is available via equivalent top-level functions.
// equivalent at runtime z.decode(stringToDate, "2024-01-15T10:30:00.000Z"); z.encode(stringToDate, new Date());
.parse() vs .decode()
Both .parse() and decode() process data in the "forward" direction. They behave identically at runtime.
stringToDate.parse("2025-08-21T20:59:45.500Z");
stringToDate.decode("2025-08-21T20:59:45.500Z");
There is an important difference however. While .parse() accepts any input, .decode() expects a strongly typed input. That is, it expects an input of type string, whereas .parse() accepts unknown.
stringToDate.parse(Symbol('not-a-string'));
// => fails at runtime, but no TypeScript error
stringToDate.decode(Symbol("not-a-string"));
// ^ ❌ Argument of type 'symbol' is not assignable to parameter of type 'Date'. ts(2345)
This is a highly requested feature unto itself:
Encoding
You can use any Zod schema with .encode(). The vast majority of Zod schemas are non-transforming (the input and output types are identical) so .decode() and .encode() behave identically. Only certain schema types change their behavior:
- Codecs — runs from
B->Aand executes theencodetransform during encoding - Pipes — these execute
B->Ainstead ofA->B - Defaults and prefaults — Only applied in the forward direction
- Catch — Only applied in the forward direction
Note — To avoid increasing bundle size unnecessarily, these new methods are not available on Zod Mini schemas. For those schemas, equivalent top-level functions are provided.
The usual async and safe variants exist as well:
// decode methods
stringToDate.decode("2024-01-15T10:30:00.000Z")
await stringToDate.decodeAsync("2024-01-15T10:30:00.000Z")
stringToDate.safeDecode("2024-01-15T10:30:00.000Z")
await stringToDate.safeDecodeAsync("2024-01-15T10:30:00.000Z")
// encode methods
stringToDate.encode(new Date())
await stringToDate.encodeAsync(new Date())
stringToDate.safeEncode(new Date())
await stringToDate.safeEncodeAsync(new Date())
Example codecs
Below are some "worked examples" for some commonly-needed codecs. These examples are all tested internally for correctness. Just copy/paste them into your project as needed. There is a more comprehensive set available at zod.dev/codecs.
stringToBigInt
Converts bigint into a serializable form.
const stringToBigInt = z.codec(z.string(), z.bigint(), {
decode: (str) => BigInt(str),
encode: (bigint) => bigint.toString(),
});
stringToBigInt.decode("12345"); // => 12345n
stringToBigInt.encode(12345n); // => "12345"
json
Parses/stringifies JSON data.
const jsonCodec = z.codec(z.string(), z.json(), {
decode: (jsonString, ctx) => {
try {
return JSON.parse(jsonString);
} catch (err: any) {
ctx.issues.push({
code: "invalid_format",
format: "json_string",
input: jsonString,
message: err.message,
});
return z.NEVER;
}
},
encode: (value) => JSON.stringify(value),
});
To further validate the data, .pipe() the result of this codec into another schema.
const Params = z.object({ name: z.string(), age: z.number() });
const JsonToParams = jsonCodec.pipe(Params);
JsonToParams.decode('{"name":"Alice","age":30}'); // => { name: "Alice", age: 30 }
JsonToParams.encode({ name: "Bob", age: 25 }); // => '{"name":"Bob","age":25}'
Further reading
For more examples and a technical breakdown of how encoding works, reads theannouncement blog post and new Codecs docs page. The docs page contains implementations for several other commonly-needed codecs:
stringToNumberstringToIntstringToBigIntnumberToBigIntisoDatetimeToDateepochSecondsToDateepochMillisToDatejsonCodecutf8ToBytesbytesToUtf8base64ToBytesbase64urlToByteshexToBytesstringToURLstringToHttpURLuriComponentstringToBoolean
.safeExtend()
The existing way to add additional fields to an object is to use .extend().
const A = z.object({ a: z.string() })
const B = A.extend({ b: z.string() })
Unfortunately this is a bit of a misnomer, as it allows you to overwrite existing fields. This means the result of .extend() may not literally extend the original type (in the TypeScript sense).
const A = z.object({ a: z.string() }) // { a: string }
const B = A.extend({ a: z.number() }) // { a: number }
To enforce true extends logic, Zod 4.1 introduces a new .safeExtend() method. This statically enforces that the newly added properties conform to the existing ones.
z.object({ a: z.string() }).safeExtend({ a: z.number().min(5) }); // ✅
z.object({ a: z.string() }).safeExtend({ a: z.any() }); // ✅
z.object({ a: z.string() }).safeExtend({ a: z.number() });
// ^ ❌ ZodNumber is not assignable
Importantly, this new API allows you to safely extend objects containing refinements.
const AB = z.object({ a: z.string(), b: z.string() }).refine(val => val.a === val.b);
const ABC = AB.safeExtend({ c: z.string() });
// ABC includes the refinements defined on AB
Previously (in Zod 4.x) any refinements attached to the base schema were dropped in the extended result. This was too unexpected. It now throws an error. (Zod 3 did not support extension of refined objects either.)
z.hash()
A new top-level string format for validating hashes produced using various common algorithms & encodings.
const md5Schema = z.hash("md5");
// => ZodCustomStringFormat<"md5_hex">
const sha256Base64 = z.hash("sha256", { enc: "base64" });
// => ZodCustomStringFormat<"sha256_base64">
The following hash algorithms and encodings are supported. Each cell provides information about the expected number of characters/padding.
| Algorithm / Encoding | "hex" |
"base64" |
"base64url" |
|---|---|---|---|
"md5" |
32 | 24 (22 + "==") | 22 |
"sha1" |
40 | 28 (27 + "=") | 27 |
"sha256" |
64 | 44 (43 + "=") | 43 |
"sha384" |
96 | 64 (no padding) | 64 |
"sha512" |
128 | 88 (86 + "==") | 86 |
z.hex()
To validate hexadecimal strings of any length.
const hexSchema = z.hex();
hexSchema.parse("123abc"); // ✅ "123abc"
hexSchema.parse("DEADBEEF"); // ✅ "DEADBEEF"
hexSchema.parse("xyz"); // ❌ ZodError
Additional changes
- z.uuid() now supports the "Max UUID" (
FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF) per the RFC $ZodFunctionis now a subtype of$ZodType
Commits
edd4fea- Closes #51275d4a315- Closes #5116f3f0955- Closes #51080114d5b- #51223b077c3- #51211e06af8- #5113b01b6f3— #5052571ab0c— #5051d3ea111— #5049b8e3f87— #4865
v4.0.17
Commits:
v4.0.16
Commits:
d589186fix: ensure keyof returns enum (#5045)4975f3afeat: add discriminator generic (#5044)0a463e3Update speakeasy files12658afFix Edit page buttons47e6604fix:edit this pagebutton, now redirects to correct url using the new path (#5056)7207a2dUpdate Hey API link to Zod v3 plugin (#5060)6887ff3Update Hey API link to Zod plugin (#5059)ffff1aaClone POJO objects during defaulting/prefaultinga227cb3v4.0.16
v4.0.15
Commits:
7e7e346Clean up docsf2949a8[docs] Fix migration guide upgrade command (#5021)d43cf19Fix recursive object initialization errors with check() and other methods (#5018)3de2b63fix: remove redundant Required<> from input and output type definitions (#5033)93553bdAdd needs info03cfa8d4.0.15
v4.0.14
Commits:
99391a8Docs: Fix typo (#5005)e25303eDocs: fix typo (#5008)dbb05efAdd JSON Schema draft-04 output (#4811)b8257d7Improve tuple recursive inference.9bdbc2fAvoid infinite loops in defineLazy. Fixes #4994.af96ad44.0.14
v4.0.13
Commits:
v4.0.12
Commits:
ff83fc9Add eslint-plugin-import-zod (#4848)7c9ce38Update docs for z.property check (#4863)c432577docs: add jwt schema docs (#4867)35e6a6fAdd llms.txt (#4915)3ac7bf0Clean up Edit this Page60a9372Implementllms-full.txt(#5004)73a19704.0.12
v4.0.11
Commits:
8e6a5f8Fix “Edit on Github” link (#4997)930a2f6Fix number of errors in doc (#4993)c762dbbfeat(locale): Add Yoruba (yo) locale (#4996)9a34a3aZod 4.0.11 (#4981)
v4.0.10
Commits:
291c1caAdd should-build scripte32d99bMove should-build scriptd4faf71Add v3 docs (#4972)dfae371Update Jazz img on v3 docsd6cd30dfix #4973 (#4974)1850496Fix typo invalype(#4960)4ec2f87Add Zod Playground to zod 4 ecosystem (#4975)2b571a2Update docs z.enum with object literal example (#4967)813451dv4.0.10 (#4978)
v4.0.9
Commits:
v4.0.8
Commits:
v4.0.7
Commits:
v4.0.6
Commits:
a3e4391Unwiden catch input type (#4870)499df78Add RFC 9562 mentions. Closes #4872d0493f3Doc tweak - spread vs destructuring (#4919)8dad394feat: Icelandic translation (#4920)2ffdae1Bulgarian (bg) translation (#4928)0973135docs: add valype to xToZodConverts (#4930)d257340Remove moduleResolution callout (#4932)075970ddocs: add coercion note to fix compile errors (#4940)b9e8a60Add@hey-api/openapi-tsto Zod 3 ecosystem (#4949)ad7b0ffAdd@hey-api/openapi-tsto Zod 3 ecosystem (#4942)4619109feat(locales): add Danish translations (#4953)cb84a57Point to zod-v3-to-v4 codemod in Zod 4 migration guide (#4954)28a5091Update api.mdx (#4955)7f3cf94Fix URL sup example (#4959)17e7f3bAdd@hey-api/openapi-tsto Zod 4 ecosystem (#4950)f75d852fix: escapes decimal place inz.literal(#4895)7dd7484v4.0.6 (#4941)
v4.0.5
Commits:
v4.0.4
Commits:
9335f05AddsZodFirstPartyTypeKindstub to fix module resolution failure insidezod-to-json-schema
v4.0.3
Commits:
5905a8dImprove check-versions scriptf3e749bRemove global File interface44a936c4.0.274006edFix JSR provenanceff4af5e4.0.3ce573e8Update test badge9a7161aFix versions
v4.0.2
v4.0.1: v4.0.0
With this release, [email protected] has been published to npm. There were no code changes between 3.25.76 and 4.0.0!
Zod 4 has been stable for the past 6 weeks, but it was published inside [email protected] on npm. this transitionary window gave the ecosystem time to incrementally support for Zod 4 (without dropping support for Zod 3). As there is now near-universal support for Zod 4 in the ecosystem, ths time feels right to finally put a bow on things 🎀
To upgrade to Zod 4:
npm upgrade zod@^4.0.0
If you’ve already migrated to Zod 4 using the subpaths, there are no changes required. however you can optionally simplify your imports (recommended)
// after upgrading to [email protected]:
import * as z from "zod"; // Zod 4 (regular)
import * as z from "zod/mini" // Zod 4 Mini
// these still work, but are no longer needed
import * as z from "zod/v4";
import * as z from "zod/v4-mini":
// if you still need Zod 3
import * as z from "zod/v3"; // Zod 3
Library authors — if you've already implemented Zod 4 support according to the best practices outlined in the Library authors guide, bump your peer dependency to include zod@^4.0.0:
// package.json
{
"peerDependencies": {
"zod": "^3.25.0 || ^4.0.0"
}
}
There should be no other code changes necessary. No code changes were made between the latest 3.25.x release and 4.0.0. This does not require a major version bump.
v4.0.0
v3.25.76
Commits:
91c9ca6fix: cleanup _idmap of $ZodRegistry (#4837)9cce1c5docs: fix typo in flattenError example on error-formatting page (#4819) (#4833)a3560aev3.25.76 (#4838)5060661Release 3.25.767baee4eUpdate index.mdx (#4831)
v3.25.75
Commits:
c5f349bFix z.undefined() behavior in toJSONSchema
v3.25.74
Commits:
v3.25.73
Commits:
v3.25.72
Commits:
4a4dac7Warn about id uniqueness check on Metadata page (#4782)7a5838dfeat(locale): Add Esperanto (eo) locale (#4743)36fe14eFix optionality of schemas (#4769)20c8c4bFix re-export bug8b0df103.25.72
v3.25.71
Commits:
v3.25.70
Commits:
bd81c7cAdd ecosystem listing to homepage1ddb971Add Mobb to sponsors30ba440Clean up ecosystem.mdx0ef1b85Addsvelte-jsonschema-formto form integrations (#4784)14715f1docs: fix Lambda spelling (#4804)f6da030Add back src (#4806)364200aRevert "Add back src (#4806)"16e1b67v3.25.70 (#4807)
v3.25.69
Commits:
f46946cImprove release workflowb6fe831Do not clobber defaults in7f986d0Skip attw test if Zod isn't built5576182Addexacttotoo_big/too_smallissue formats (#4802)8fd2fc33.25.69
v3.25.68
Commits:
d3e0f86feat: add zod-xlsx back to the ecosystem.tsx (#4718)86112d9chore: update lint-staged from v12 to v16 (#4703)218a267chore: remove unused octokit (#4708)a7cb6edfix(v4): add exact to length check issue (#4617)b888170Close #40355879bafFix fmtbd1bddaFix buildddadfb8Simplify basics, document reportInputd5e2368Addz.stringFormat()(#4737)ee5615dDrop example and examples entirely4080fd9Add treeshaking discussion to docscf6157aDocs39947acUse import star everywhere7e296aeWIPbb42be4Update treeshake target0a49fa3Improve mini docs1b0a5e5Add dep90fa0cdSwitch tozshy(#4777)af3841bRename play.tscf12ccf3.25.6834ae421Update snapshot
Configuration
📅 Schedule: Branch creation - Between 12:00 AM and 03:59 AM, only on Monday ( * 0-3 * * 1 ) (UTC), Automerge - At any time (no schedule defined).
🚦 Automerge: Enabled.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
- [ ] If you want to rebase/retry this PR, check this box
This PR was generated by Mend Renovate. View the repository job log.