zod icon indicating copy to clipboard operation
zod copied to clipboard

[Feature Request] Load JSONSchema

Open TrueWill opened this issue 2 months ago • 2 comments

Feature Request: Load JSONSchema

Problem Statement

While Zod has toJSONSchema, it has no (obvious) way to import an existing JSON Schema.

Proposed Solution

Add a fromJSONSchema(string) method that returns a Zod schema.

TrueWill avatar Dec 03 '25 18:12 TrueWill

I'll appreciate supporting this feature as well, since json-schema-to-zod is going to be deprecated soon, a native solution would be appreciated.

dean-ab avatar Dec 07 '25 12:12 dean-ab

I do realize this is significantly more complex than toJSONSchema; however I feel it would help adoption from users of Ajv and other libraries.

TrueWill avatar Dec 07 '25 18:12 TrueWill

I've been playing a bit with the experimental api fromJSONSchema: https://zod.dev/json-schema?id=zfromjsonschema, it works well so far as a drop in replacement for json-schema-to-zod

One thing missing though would be the ability to do codegen and be able to write the zod type to a generated file - any chance this is planned or doable in the current state ?

jbsouvestre avatar Dec 16 '25 09:12 jbsouvestre