JSON to Zod

Paste JSON and get Zod schemas plus inferred TypeScript types. Detects integers, nullable and optional fields. Free and runs in your browser.

How to convert JSON to Zod

  1. Paste a JSON object or array, for example a response from the API you are calling.
  2. Set the name of the root type.
  3. Copy the generated Zod code into your project.

What you get

Tips for accurate results

The generator only knows the sample you paste. Include arrays with several items and responses where optional fields are present, so it can tell which keys are always there, which can be null and which numbers have decimals.

Frequently asked questions

Is my JSON sent to a server?

No. The code is generated in your browser, so API responses and other private data never leave your device.

Why use Zod instead of plain TypeScript types?

TypeScript types disappear at runtime, so they cannot check data coming from an API. A Zod schema validates the data when it arrives and gives you the type for free with z.infer.

Which Zod version does the output target?

The generated code uses z.object, z.array, z.union, .nullable() and .optional(), which work the same in Zod 3 and Zod 4.

How are null values handled?

A key that is null in some samples and a string in others becomes z.string().nullable(). A key that is always null becomes z.null(); replace it with the real type once you know it.