Blogmark
Introducing Zod 4 beta
via jbranchaud@gmail.com
Several years in the making, Zod 4 is now in beta with a ton of performance improvements, bundle size improvements, and some new features.
Zod 4 is now in beta after over a year of active development. It's faster, slimmer, more tsc-efficient, and implements some long-requested features.
The things that caught my attention were:
- JSON Schema conversion -- this makes a schema serializable and portable to other contexts and even languages.
- Error Pretty Printing -- this is huge for dev server logs and scripting output because the errors are way more readable and don't completely blowout the terminal scroll back buffer.
- StringBool -- this seems nice for CLIs or JSON parsing where you know you're in a certain domain with specific truthy and falsy values
- Refinements and Overwrites -- the under-the-hood changes that allow refinements to be mixed in with other schema methods. Overwrites allow for same-type transformations that work with JSON schema conversion.
One of the headline features is Metadata and Schema Registeries which looks cool, but I can't see how I'd use it for anything I've done with Zod up to now. The best I can tell is that a library like OpenAPI or a form library would use it to essentially annotate a schema with additional metadata.
I've only mentioned a handful of the features, but the whole post is worth digging into. Matt Pocock also did an overview in Zod 4 is out, and it is CRAZY on his Youtube Channel.