JSON to Zod

JSON to Zod converter

Paste strict JSON and generate a deterministic Zod 4 schema to review and copy—it runs in your browser.

0 / 524,288 bytes

Paste strict JSON. Comments and trailing commas aren’t accepted.

Zod output

Generated source is plain text and stays selectable.

Your generated Zod 4 schema will appear here.

Review the schema against the upstream API contract before using it in production.

A first schema, with its assumptions visible

One JSON sample cannot prove an API contract. The converter stays conservative and calls out the places that need your review.

How inference works

Strings, booleans and finite numbers map to matching Zod primitives. Object keys are kept in source order and safely quoted. Arrays inspect every item, merge compatible object shapes and use stable unions when values conflict.

The result includes a Zod 4 import, an exported RootSchema and an inferred Root TypeScript type.

JSON and Zod 4 limits

Input must be strict JSON: comments and trailing commas are rejected. Empty arrays use an unknown item type, empty objects use an unknown record, and null-only values produce a review warning.

JavaScript parses numbers as IEEE-754 values, so very large integers can lose precision and extreme decimals can round or underflow before inference. Input is limited to 512 KiB, 64 container levels and 50,000 values; generated source is limited to 2 MiB.

Privacy

Conversion runs in browser memory. Your JSON and generated schema are not sent to a product server, placed in a URL or saved by this tool. Copying happens only when you choose Copy schema.

Review required fields, unions, nullability and numeric constraints against the upstream API contract before using the generated schema in production.

Common questions

Does the converter infer dates, URLs or email addresses?

No. JSON strings become z.string(). A sample value alone is not enough to prove a more specific format.

Will the generated schema be complete?

It describes the sample you provide and accepts every observed array item. It cannot discover fields, variants or constraints that are absent from that sample, so compare it with the real API contract.