🔮 OSS Fellow @ Clerk
🦆 Friendly neighborhood TypeScript nerd
🧑🏼💻 Prev @ Bun, EdgeDB, YC, MIT
✅ stringToNumber
✅ stringToInt
✅ stringToBigInt
✅ numberToBigInt
✅ isoDatetimeToDate
✅ epochSecondsToDate
✅ epochMillisToDate
✅ jsonCodec
✅ utf8ToBytes
✅ bytesToUtf8
✅ base64ToBytes
✅ base64urlToBytes
✅ hexToBytes
✅ stringToURL
✅ uriComponent
✅ stringToNumber
✅ stringToInt
✅ stringToBigInt
✅ numberToBigInt
✅ isoDatetimeToDate
✅ epochSecondsToDate
✅ epochMillisToDate
✅ jsonCodec
✅ utf8ToBytes
✅ bytesToUtf8
✅ base64ToBytes
✅ base64urlToBytes
✅ hexToBytes
✅ stringToURL
✅ uriComponent
fully-tested versions of 16 commonly-needed codecs are available on the new Codecs page. you're encouraged to copy/paste/customize them as needed 👍
zod.dev/codecs
fully-tested versions of 16 commonly-needed codecs are available on the new Codecs page. you're encouraged to copy/paste/customize them as needed 👍
zod.dev/codecs
good question! they're identical at runtime, but their type signatures differ in an important way.
unlike .parse()—which accepts `unknown` input—decode and encode expect strongly-typed inputs
good question! they're identical at runtime, but their type signatures differ in an important way.
unlike .parse()—which accepts `unknown` input—decode and encode expect strongly-typed inputs
.decode() — "forward" parsing
.encode() — "reverse" parsing
.decode() — "forward" parsing
.encode() — "reverse" parsing
though actually in Zod 4, z.object() adds the "?"to T.optional() but not to z.union(T, z.undefined()) as you're suggesting...a small change that makes things a little more sound
though actually in Zod 4, z.object() adds the "?"to T.optional() but not to z.union(T, z.undefined()) as you're suggesting...a small change that makes things a little more sound
v4.zod.dev/packages/core
v4.zod.dev/packages/core
v4.zod.dev/v4/changelog
v4.zod.dev/v4/changelog