Summary
Highlights
Zod 4 beta is announced with significant performance improvements over Zod 3, including faster string, array, and object parsing. TypeScript performance is also vastly improved, reducing type instantiations in large codebases.
Zod 4 features a smaller bundle size. Zod Mini, a new tree-shakable sister library, further reduces bundle size, making Zod more suitable for front-end environments. It uses wrapper functions instead of methods for better tree-shaking.
Zod 4 introduces first-class JSON schema conversion, which is useful for AI applications involving structured outputs and tool calling. The z.toJSJSONSchema function allows to creating a JSON schema from Zod schemas.
Zod 4 implements new system `meta` for adding strongly typed metadata to schemas, stored in a schema registry decoupled from the schemas themselves. `describe` still works but it's not recommended anymore.
Z.inface API to define object types with exact optional properties and recursive types. Solves the problem of representing key optional and value optional properties, and simplifies recursive type definitions without nasty maneuvers.
Zod now validates file instances using Z.File with checks for minimum size, maximum size, and MIME type, which improves handling form data file uploads.
Zod introduces a local API for translating error messages into different languages. Zod now implements a top-level z.pritifyError function so you get a really gorgeous pretty printable multi-line string. All string formats like email and IPs etc. are moved to the top level of the module.
Zod 4 brings Z.lateLiteral to convert one to one from Zod into Typescript template literal types. Z.stringBool converts strings to booleans with customizable truthy/falsy values, which is useful for query parameters.
The presenter expresses excitement about the new features in Zod 4 and mentions needing to update their Zod tutorial. The presenter promotes his AI course.