A free browser tool that converts any JSON object or array into a fully typed Zod validation schema. Handles nested objects, arrays, union types, nullable fields, and optional fields — with one-click copy.

JSON to Zod is a free, browser-based tool that converts any JSON object or array into a fully typed Zod schema in milliseconds. Paste your JSON, adjust options (optional fields, include import, schema name), and copy the TypeScript-ready output. No account, no server uploads, 100% client-side.
Zod is now the de facto runtime validation library for TypeScript projects. But writing Zod schemas by hand from an existing JSON payload is tedious and error-prone:
{
"id": 1,
"name": "Alice",
"email": "alice@example.com",
"address": {
"street": "123 Main St",
"city": "Springfield"
},
"tags": ["admin", "user"]
}To validate this, you need to write:
import { z } from "zod";
export const userSchema = z.object({
id: z.number().int(),
name: z.string(),
email: z.string(),
address: z.object({
street: z.string(),
city: z.string(),
}),
tags: z.array(z.string()),
});
export type User = z.infer<typeof userSchema>;With deeply nested objects, this becomes a multi-minute chore. Copy a JSON response from Postman or a browser DevTools panel and you want the schema immediately — not after ten minutes of typing.
Paste any valid JSON object, array, or primitive into the input panel. The conversion starts immediately — no button press required.
Three options control the output:
const name (auto-converts to camelCase).optional() for partial shapesimport { z } from "zod" to the outputClick "Copy Schema" to copy the full TypeScript Zod schema to your clipboard. Paste it directly into your project.
The converter uses recursive type inference to produce accurate Zod types:
| JSON Type | Zod Output |
|:---|:---|
| "string" | z.string() |
| 42 (integer) | z.number().int() |
| 3.14 (float) | z.number() |
| true / false | z.boolean() |
| null | z.null() |
| [...] (homogeneous) | z.array(z.string()) etc. |
| [...] (mixed types) | z.array(z.union([...])) |
| {...} (object) | z.object({...}) (recursive) |
| Unknown | z.unknown() |
The converter distinguishes integers (z.number().int()) from floats (z.number()) by checking Number.isInteger(value). This is more accurate than most similar tools that use z.number() for everything.
When an array contains multiple types — e.g. [1, "two", true] — the converter generates z.array(z.union([z.number().int(), z.string(), z.boolean()])) rather than falling back to z.unknown().
Nested objects are converted recursively with correct indentation, so even complex API responses with five or six levels of nesting produce readable, correctly indented schemas.
z.number().int() for whole numbersz.union([...]) for heterogeneous arrays.optional()const namez.infer<typeof schema> type automatically@t3-oss/env-nextjs)The converter is a single recursive function:
function getZodType(value: JsonValue, indent: number, makeOptional: boolean): string {
if (value === null) return makeOptional ? "z.null().optional()" : "z.null()";
if (Array.isArray(value)) { /* union detection + z.array() */ }
if (typeof value === "object") { /* recursive z.object() */ }
if (typeof value === "string") return makeOptional ? "z.string().optional()" : "z.string()";
if (typeof value === "number") {
const base = Number.isInteger(value) ? "z.number().int()" : "z.number()";
return makeOptional ? `${base}.optional()` : base;
}
if (typeof value === "boolean") return makeOptional ? "z.boolean().optional()" : "z.boolean()";
return makeOptional ? "z.unknown().optional()" : "z.unknown()";
}The optional flag is threaded recursively so every field at every nesting level gets .optional() when enabled. The output function wraps the schema in a named const with an z.infer type export.
You're integrating a third-party API. Copy the JSON response from Postman into the converter, get the Zod schema, and add runtime validation to your fetch call in 30 seconds.
tRPC uses Zod for input validation. Instead of writing schemas manually to match your client payloads, paste the example payload and get the schema ready.
React Hook Form uses Zod via the zodResolver adapter. Paste the shape of your form's default values and get a validation schema with one copy.
When prototyping, paste sample JSON data and get both a Zod schema and a TypeScript type from z.infer simultaneously. Faster than writing interfaces by hand.
Express, Fastify, and Hono all work with Zod for body parsing validation. Paste the expected request body shape, copy the schema, and wire it up in your handler.
If you're new to Zod, seeing how different JSON structures map to Zod methods is the fastest way to learn the API. Paste a JSON object, see the output, modify it, see how it changes.
Zod is the most-downloaded TypeScript validation library. As of 2025, it's a standard dependency in nearly every tRPC project, T3 stack application, and modern TypeScript API. Developers write Zod schemas constantly.
The friction is always the same: you have JSON data from an API response, a database query result, or a form payload, and you need to write a Zod schema for it. The mapping is mechanical — it should be instant.
Existing solutions either require a Node.js CLI, produce schemas that don't handle edge cases (integers vs. floats, mixed arrays), or are buried inside larger tools that are overkill for a single paste-and-copy operation.
JSON to Zod is the focused tool that covers this one workflow completely, runs in the browser, and requires no setup.
Try it now: json-to-zod.tools.jagodana.com
The client needed a robust developer tools solution that could scale with their growing user base while maintaining a seamless user experience across all devices.
We built a modern application using TypeScript and Zod, focusing on performance, accessibility, and a delightful user experience.
Category
Developer Tools
Technologies
Date
July 2026
More work in Developer Tools