Skip to content
Discussion options

You must be logged in to vote

Stability of z.toJSONSchema() in Zod 4

To answer your core question directly: The output structure of z.toJSONSchema() for standard primitives and structural combinators is treated as stable and normative under SemVer, specifically because the wider ecosystem (OpenAPI generators, AI function-calling schemas, and tooling) depends on deterministic output.

Here is what you can rely on, along with two critical architectural caveats for binary wire serialization:


1. What is Guaranteed and Stable

  1. Standard Specification Target (Draft 2020-12):
    Zod 4’s toJSONSchema targets JSON Schema Draft 2020-12. This means:
    • Tuples will consistently emit prefixItems (not the obsolete Draft 7 array-of-schemas …

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by ChiChuRita
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants