Utilify

JSON to Zod Schema Converter

Convert JSON to a Zod schema instantly. Infers email, UUID, URL, and datetime formats, merges array shapes with .optional(), and outputs Zod v4 or v3 code. Free, browser-only.

How to use JSON to Zod

  1. 1
    Paste your JSON

    Paste a sample JSON payload — an API response, a config file, or fixture data — into the left pane.

  2. 2
    Pick Zod v4 or v3

    Choose the output style. v4 uses the new top-level validators like z.email() and z.iso.datetime(); v3 uses z.string().email() chains.

  3. 3
    Name your schema

    Set the schema name — the exported const and the inferred TypeScript type are named after it.

  4. 4
    Copy the code

    The Zod schema updates live as you type. Click Copy and paste it straight into your project.

About JSON to Zod

Zod is the de-facto validation library of the TypeScript ecosystem: you define a schema once and get both runtime validation and a static type from the same source of truth. The tedious part is writing that schema by hand when the shape already exists as JSON — an API response you just received, a config file, a database row. This converter does the transcription for you: paste JSON, get a ready-to-import Zod schema plus a z.infer type export.

It goes beyond a mechanical one-to-one mapping. String values are inspected and, when they match, emitted as the stricter Zod validators — z.email(), z.uuid(), z.url(), and z.iso.datetime() for ISO 8601 timestamps — so the generated schema actually validates instead of accepting any string. Format inference is conservative: if the samples in an array disagree, it falls back to plain z.string() rather than guessing. You can switch inference off entirely when you want the loosest schema.

Arrays of objects get real shape merging. Every element is examined, and a key that appears in some elements but not others is marked .optional() — the detail hand-written schemas most often get wrong, and one that single-element converters cannot see at all. Mixed-type arrays become z.union(), null-and-value mixes become .nullable(), whole-number samples become z.number().int(), and non-identifier keys are quoted correctly.

The output targets Zod v4 by default, using the current top-level validator style, with a one-click switch to classic v3 chains for older codebases. Everything runs entirely in your browser — your payloads, which often contain real user data, never leave your device. Paste, copy, and keep the schema as the single source of truth it was meant to be.

When to use JSON to Zod

  • Typing an external API

    Paste a real response from a third-party API and get a schema that validates it at the boundary, plus the TypeScript type for free.

  • Validating config files

    Turn a JSON config into a schema so bad deploys fail fast at startup with a clear Zod error instead of deep in runtime.

  • tRPC / server action inputs

    Generate the input schema for a procedure from an example payload instead of writing z.object({...}) by hand.

  • Migrating hand-written types

    Convert existing JSON fixtures into Zod schemas when adopting runtime validation in a codebase that only has interfaces.

Frequently asked questions

Does it detect string formats like email and UUID?+

Yes. Strings that look like emails, UUIDs, URLs, or ISO 8601 datetimes are emitted as z.email(), z.uuid(), z.url(), and z.iso.datetime() (or the z.string().email() style for Zod v3). Detection is conservative — if the values in an array are inconsistent, it falls back to plain z.string() — and you can turn inference off.

How are arrays of objects handled?+

All elements are merged into one shape. A key that is present in some elements but missing from others becomes .optional(), mixed types become z.union(), and values that mix null with something else become .nullable(). One-sample converters cannot do this.

What is the difference between the Zod v4 and v3 output?+

Zod v4 moved string format validators to the top level: z.email() instead of z.string().email(), and z.iso.datetime() instead of z.string().datetime(). The toggle switches between the two styles; the rest of the schema is identical and works in both versions.

Why does the output include a z.infer type export?+

The main reason to use Zod is that the schema doubles as the type. The generated export type Schema = z.infer<typeof schema> line gives you the static TypeScript type derived from the schema, so you never write the shape twice.

Is my JSON uploaded anywhere?+

No. Parsing, inference, and code generation all run in your browser. API responses and payloads — which often contain real user data — never leave your device.

Related tools

From the blog