JSON Schema to Zod: Understanding the Difference
Table of Contents
JSON Schema and raw JSON are two different things. JSON Schema is a standard for describing the structure of JSON data (like a blueprint). Raw JSON is the actual data. Our converter accepts raw JSON and generates a Zod schema from it. If you have a JSON Schema document (with fields like "$schema", "type", "properties"), that is a different input format with different conversion tools.
This page explains the distinction clearly and points you to the right tool for each case.
Raw JSON vs JSON Schema: The Difference
Raw JSON — actual data:
{
"id": 1,
"name": "Alice",
"email": "[email protected]",
"active": true
}
JSON Schema — a document describing the expected structure:
{
"$schema": "http://json-schema.org/draft-07/schema",
"type": "object",
"properties": {
"id": { "type": "integer" },
"name": { "type": "string" },
"email": { "type": "string", "format": "email" },
"active": { "type": "boolean" }
},
"required": ["id", "name", "email"]
}
JSON Schema is itself a JSON file, but it describes a schema rather than containing real data. Our converter works with the first case — real data — not the second.
What Our JSON to Zod Tool Does
The free JSON to Zod converter accepts raw JSON data and generates a Zod schema by inferring types from the actual values:
"Alice"→z.string()42→z.number()true→z.boolean()null→z.null(){...}→z.object({...})[...]→z.array(...)
This is useful when you have a real API response, a config file, or a database record and want to generate a validation schema from it quickly.
Sell Custom Apparel — We Handle Printing & Free ShippingWhat to Use for JSON Schema → Zod Conversion
If you have an actual JSON Schema document (with "$schema", "type", "properties"), you need a different converter. The most commonly used library for this is json-schema-to-zod on npm:
npm install json-schema-to-zod
import { jsonSchemaToZod } from "json-schema-to-zod";
const schema = {
type: "object",
properties: {
name: { type: "string" },
age: { type: "integer" }
}
};
console.log(jsonSchemaToZod(schema));
// Outputs: z.object({ name: z.string(), age: z.number().int() })
This programmatic approach handles the full JSON Schema spec including required fields, format validators, allOf/anyOf/oneOf, and more.
Which Approach to Use for Your Situation
| You have... | Use... |
|---|---|
| A real API response (actual data) | Our free browser converter |
| A Postman response body | Our free browser converter |
| A config file with real values | Our free browser converter |
| A JSON Schema document ($schema, properties) | json-schema-to-zod npm package |
| An OpenAPI/Swagger spec | openapi-zod-client or similar |
| A Prisma schema | zod-prisma or prisma-zod-generator |
For the most common case — converting real data from an API or config file to a Zod schema — paste it into the free converter and get a working schema in seconds.
Try It Free — No Signup Required
Runs 100% in your browser. No data is collected, stored, or sent anywhere.
Open Free JSON to Zod ConverterFrequently Asked Questions
What is the difference between JSON Schema and JSON?
JSON is data. JSON Schema is a standard for describing the expected structure of JSON data — it uses JSON syntax but is a blueprint, not actual values. Fields like "$schema", "type", and "properties" are JSON Schema keywords.
Can I convert a JSON Schema document to a Zod schema?
Yes, but not with a browser paste tool. Use the json-schema-to-zod npm package, which handles the full JSON Schema spec including required fields, format validators, and composition keywords.
My JSON has $schema at the top — can I still use the browser converter?
The converter will read the $schema field as a string value and generate z.string() for it. It treats your JSON Schema document as raw data, not as a schema definition. Use json-schema-to-zod instead for proper conversion.
Can I generate a Zod schema from a real API response?
Yes. Paste the actual JSON response (not a schema document) into the free converter at /developer-tools/json-to-zod/. It generates the z.object() schema immediately from the data values.

