Converts JSON Schema (draft 4+) objects or files into Zod schemas as JavaScript/TypeScript code. Current stable version is 2.8.1. Release cadence is irregular with maintenance mode. Key differentiators: supports Zod v3 and v4 output, CLI and programmatic usage, zero runtime dependencies (formatting and ref resolution delegated to external tools since v2). Deprecated as of March 2026.
npm install json-schema-to-zodNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Converts a simple JSON Schema object to a Zod schema string using programmatic API.
Consider migrating to alternative libraries or maintain a fork. For JSON Schema to Zod conversion, the package remains functional but unmaintained.
Pipe output through prettier and resolve $refs with json-refs separately: json-refs resolve schema.json | json-schema-to-zod | prettier --parser typescript > output.ts
Pass option { zodVersion: 3 } or use CLI flag --zodVersion 3 to generate Zod v3 compatible code.Increase depth with e.g., { depth: Infinity } or a specific number to handle recursive schemas.Install zod as a dependency: npm install zod
Use named import: import { jsonSchemaToZod } from 'json-schema-to-zod'Provide input via piped JSON or use -i flag: json-schema-to-zod -i schema.json
Ensure input file is valid JSON. Use a linter or validator to check syntax.
No dependency data recorded yet.