JSON Schema ⇄ Zod Converter
Convert JSON Schema to Zod and Zod back to JSON Schema — built for LLM structured outputs and function calling. Maps formats, enums, const, unions, $ref, nullable, defaults and descriptions, with a one-click strict mode (additionalProperties:false + all required) for OpenAI/Anthropic tool definitions. Runs entirely in your browser.
About this ToolHow it works, benefits & use casesTap to collapse
The JSON Schema ⇄ Zod Converter is a two-way bridge between JSON Schema (draft 2020-12 / OpenAPI-style) and Zod schema source, built specifically for the LLM era where the same shape has to live in two places at once: a JSON Schema for an OpenAI or Anthropic function-calling / structured-output request, and a Zod schema for validating the model’s reply in TypeScript. Going forward, paste a JSON Schema and get clean Zod source — objects with proper required vs `.optional()` fields, `additionalProperties:false` rendered as `.strict()`, string formats mapped to `.email()` / `.url()` / `.uuid()` / `.datetime()`, numeric and length bounds, `enum` and `const`, `anyOf`/`oneOf` unions, `allOf` intersections, nullable types, defaults, descriptions, and local `$ref` pointers resolved inline. Going in reverse, paste a common subset of Zod and get back pretty-printed JSON Schema you can hand straight to a model’s tool definition, with an optional strict mode that adds `additionalProperties:false` and marks every property required — exactly what the major function-calling APIs demand. Everything runs in your browser, never throws on bad input, and flags anything it can’t fully translate with an inline note so you’re never guessing.
How to Use
- 1Choose a direction at the top: "JSON Schema → Zod" to generate Zod source, or "Zod → JSON Schema" to generate a schema.
- 2Paste your source into the editor on the left (JSON Schema, or a z.object({…}) expression), or hit a "Load example" button.
- 3Set the schema / const name used in the generated Zod export, e.g. User or SearchArgs.
- 4For JSON Schema → Zod, tick "Export inferred type" to also emit `export type Name = z.infer<typeof Name>`.
- 5For Zod → JSON Schema, tick "Strict mode" to add additionalProperties:false and require every property — what OpenAI/Anthropic function-calling needs.
- 6Copy, download (schema.ts or schema.json), share the URL, or pipe the output into another tool.
Key Benefits
- Truly bidirectional: JSON Schema → Zod and Zod → JSON Schema in one tool
- Built for LLM structured outputs and function calling, with a one-click strict mode
- Maps formats, enums, const, unions, intersections, nullable, defaults, descriptions, and $ref
- Reverse direction parses Zod with a real tokenizer — never eval, never executes your code
- Never throws: invalid input degrades to a safe result with an inline // note explaining why
- Useful, copy-ready examples: a User object, an API response, an LLM tool call, and a $defs schema
- Runs entirely client-side — schemas never leave your browser; shareable URL + pipe-to-tool output
Common Use Cases
- Turning an OpenAI/Anthropic function-call JSON Schema into a Zod validator for the model’s response
- Generating a strict JSON Schema from an existing Zod schema to use as a tool/function definition
- Migrating backend JSON Schema contracts into front-end Zod validation without hand-translating
- Keeping a shared data shape in sync across a TypeScript app and a JSON-Schema-driven API
- Quickly sanity-checking how a JSON Schema construct (const, anyOf, $ref) maps onto Zod
JSON Schema
Paste a JSON Schema (draft 2020-12 / OpenAPI-style). $ref into $defs / definitions is resolved inline.
Options
Used as export const <name> = …
Also emits: export type Name = z.infer<typeof Name>
One shape, two homes
LLM apps keep the same data shape in two places: a JSON Schema for the model’s function-calling / structured-output request, and a Zod schema to validate the reply in TypeScript. This converter goes both ways — formats, enums, const, unions, $ref, nullable, defaults and descriptions included — so you never hand-translate. The reverse parser supports a documented Zod subset: z.object z.string z.number z.boolean z.null z.array z.enum z.literal z.union .optional() .nullable() .min(n) .max(n) .int() .email() .url() .uuid() .datetime() .default(x) .describe(...) .regex(/.../) .strict().
Drop into your TypeScript app to validate model output
import { z } from 'zod';
export const User = z.object({
id: z.string().uuid(),
name: z.string().min(1).max(80),
email: z.string().email(),
age: z.number().int().min(0).max(120).optional(),
role: z.enum(['admin', 'editor', 'viewer']).default('viewer').optional(),
isActive: z.boolean().describe('Whether the account is enabled').optional(),
tags: z.array(z.string()).max(10).optional(),
}).strict();
export type User = z.infer<typeof User>;Was this tool helpful?
Share Your Experience
Help others discover this tool!
Related guide
Related tools
- AI Token Counter & Cost EstimatorCount tokens and estimate API cost across GPT, Claude, Gemini & more — with a live multi-model comparison and context-window fit
- Color ConverterConvert between HEX, RGB, HSL, and HSV
- cURL to Code ConverterConvert cURL commands to code in various languages
- HTML to MarkdownConvert HTML to Markdown
- JSON to CSVConvert JSON to CSV format
- npm to Yarn ConverterConvert npm commands and package-lock.json to Yarn equivalents
The Zod Schema Generator turns TypeScript types or JSON examples into Zod. This tool is the JSON Schema bridge: it converts a real JSON Schema document into Zod and — uniquely — converts Zod source back into JSON Schema. If you are working with OpenAPI specs, function-calling tool definitions, or structured-output schemas, this is the converter you want.
When generating JSON Schema from Zod, strict mode recursively adds `additionalProperties: false` to every object and lists every property in `required`. OpenAI Structured Outputs and Anthropic tool use require this exact shape — no extra keys, all fields present — so the model is forced to return a value that matches your schema exactly. One checkbox produces a schema you can drop straight into a tool definition.

