L LocalUse Source

JSON to Zod

Paste JSON and get a Zod schema you can drop straight into a project, including the inferred TypeScript type. Detected formats become real validators rather than bare z.string().

Root type name
Zod version
JSON
Output

Output appears here as you type.

Runs entirely in your browser. Nothing you paste here is uploaded or stored.

Questions

Is my JSON uploaded anywhere?

No. Inference and code generation run entirely in your browser. Nothing is sent to a server, so pasting a real API response with customer data or internal URLs is safe.

Should I paste one object or an array of them?

An array, whenever you have one. Every element is merged into a single shape, so a field that is missing from some records becomes optional and a field that is sometimes null becomes nullable. One object can only ever tell the generator that everything is required.

Does it target Zod 3 or Zod 4?

Both - pick your version in the options. Zod 4 promoted the string formats to top-level schemas (z.email(), z.uuid(), z.iso.datetime()), while Zod 3 uses the chained z.string().email() form. The generator emits whichever your project is on.

Why is a field .optional() rather than .nullable()?

They mean different things and the generator distinguishes them. A key absent from some samples becomes .optional(); a key present but sometimes null becomes .nullable(). A key that is both gets both.

More code generation tools