The JSON to Zod converter turns a sample JSON document into a ready-to-use Zod v4 schema. Paste an API response and get z.object schemas describing its shape, so you can validate untrusted data at runtime and get a matching TypeScript type inferred from the same schema.
Generation happens entirely in your browser — nothing you paste is uploaded, logged or sent to a server. You can turn a real production payload into a schema without it ever leaving your machine. It is free and needs no account.
It is built for TypeScript developers who already reach for Zod to parse request bodies, environment variables and third-party responses, and want an accurate first-draft schema instead of hand-writing every field.
Each nested object becomes its own const XSchema = z.object({ ... }) and the parent references it by name. This produces clean, reusable schemas instead of one deeply inlined blob, matching how you would compose them by hand.
When the input is an array of objects that don't all share the same keys, optional detection appends .optional() to the keys missing from some elements. This captures the real, sometimes-present shape of list data rather than assuming every field is always present.
Toggle whether each schema is prefixed with export. With export on, the tool also emits type X = z.infer<typeof XSchema> next to every schema, so you get both the runtime validator and the static type in one paste.
Values are inferred as z.string(), z.number(), z.boolean() and z.null(); an empty array becomes z.array(z.unknown()) and a field that is null in the sample becomes z.null(). A single example can't show every case, so widen those (for example to .nullable()) by hand.
Paste your JSON on the left and the tool infers a Zod v4 schema on the right instantly. Nested objects become separate named z.object schemas and arrays are inspected to type their elements. Copy the output straight into your project — it emits the import { z } from "zod" line for you.
The generated code targets Zod v4 (z.object, z.string, z.number, z.array, z.union, z.optional). It is plain text you copy into your own project — this tool does not bundle or run Zod, so make sure zod is installed in your app.
With optional detection on and an array of objects as input, any key that is absent from at least one element gets .optional(). A single object gives no evidence of optionality, so all of its keys are treated as required.
The sample didn't carry enough information — a null value can only be inferred as z.null(), and an empty array becomes z.array(z.unknown()). Provide a fuller example, or widen the schema by hand (for example z.string().nullable()).
Yes. The schema is generated locally in your browser with JavaScript — the JSON is never uploaded or sent anywhere. You can disconnect from the internet and it still works.