JSON:API to Zod

Paste any JSON:API document — single resource, collection, or compound document with included — and get a Zod schema for data, attributes, relationships, and links you can validate at the boundary.

JSON input valid
Zod output

      
    

About this conversion

JSON:API enforces a strict envelope (type, id, attributes, relationships, links, included), and the spec evolves more slowly than the per-resource attributes inside it. That makes the envelope easy to validate, and the attributes the place where shape drift bites you. A generated Zod schema captures both layers in one paste: the envelope you can rely on across every resource type, and the attributes shape pinned to the document you actually fetched.

Use the result on the frontend (Ember Data, JSON:API-Ruby, Laravel JSON:API consumers) where validating server responses with a single .parse call is much cheaper than wrapping every property access in optional chaining. For paginated collections, swap data into a z.array of the same item schema; for compound documents, the included array is typed as a union of related-resource schemas you can narrow on resource.type.

Same shape, other validators

Other JSON shapes