{ }jsonkit
Tools/Convert/JSON to Zod
Search tools…⌘K
Format
{ }JSON Formatter
≡→JSON Minifier
\"JSON Escape / Unescape
a→zJSON Sorter
⇄{}JSON Flattener
Validate
JSON Validator
±JSON Diff / Compare
§JSON Schema Generator
JWT Decoder
ΔJSON Patch / Merge Patch
kbJSON Size Analyzer
Convert
→csvJSON to CSV
csv→CSV to JSON
⇄ymlJSON ⇄ YAML
⇄xmlJSON ⇄ XML
→tsJSON to TypeScript
b64Base64 Encode / Decode
%2FURL Encode / Decode
clkTimestamp Converter
→zJSON to Zod
→pyJSON to Pydantic
→goJSON to Go
→javaJSON to Java
⇄jsonlJSON ⇄ JSONL
5→JSON5 / JSONC to JSON
Query
$.JSONPath / JQ Tester
.*Regex Tester
Generate
Mock JSON Data Generator
idUUID / NanoID Generator
#Hash Generator
→z

JSON to Zod Schema Generator

Infer a Zod v4 schema with nested named object schemas.
processes as you type · client-side
Sample
Upload
Optional detection
export keyword
⧉ Copy output ⌘C
Download
Share
Clear
Input219 B · paste or drop a file
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Zod schema
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
import { z } from "zod" export const PlanSchema = z.object({ tier: z.string(), seats: z.number(), renews: z.string(), }); export type Plan = z.infer<typeof PlanSchema>; export const RootSchema = z.object({ id: z.string(), name: z.string(), email: z.string(), active: z.boolean(), roles: z.array(z.string()), plan: PlanSchema, }); export type Root = z.infer<typeof RootSchema>;
✓ valid (RFC 8259)219 B → 398 B0.0 msLn 1, Col 1UTF-8

About JSON to Zod

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.

How it works

Nested named schemas

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.

Optional-property detection

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.

The export keyword and inferred types

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.

Type inference and its limits

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.

Frequently asked questions

How to convert JSON to a Zod schema?

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.

Which version of Zod does the output target?

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.

How does it decide which properties are optional?

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.

Why did a field come out as z.null() or z.unknown()?

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()).

Is it safe to paste production JSON here?

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.