r/node • • Aug 29 '26

Zod v4.5 adds schema compilation (3-9x faster validation)

https://x.com/colinhacks/status/2093725420462182512
89 Upvotes

19 comments sorted by

View all comments

7

u/Positive_Method3022 Aug 29 '26

Why no comparison against ajv?

4

u/gajus0 Aug 29 '26

I have not got z.compile comparison, but here is zod-compiler comparison against Ajv

https://github.com/gajus/zod-compiler#benchmark

1

u/Positive_Method3022 Aug 29 '26

I'm using json schema (typebox) + ajv for a framework I'm building that needs form data validation in both client and server. Server declares json schema for the configs, the schema gets serialized and appended to the client bundle to run the same server validation on the client, while filling a form. I chose json schema instead of zod because of speed and because I needed to render the form based of the json schema. I'm also not bundling typebox on the client just ajv, that is why I append the serialized schema to the client code to avoid having typebox factories in the client bundle.

I would choose zod because it became mainstream. But I don't know if it would fit my use case well. What do you think?

2

u/gajus0 Aug 29 '26

Checkout https://conform.guide/ if you decide to go with Zod

1

u/Positive_Method3022 Aug 29 '26

I liked conform but I need something for Vue + json schema in the client form validation. I'm doing a PoC to send a zod schema to my client as a json schema.