05 Convert

JSON Schema to Zod

Turn a JSON Schema into Zod code for runtime validation. Formats, length and number limits carry over, and the output runs on Zod 3 and Zod 4.

Code editor. Press Escape, then Tab, to move focus out of the editor.

      How to convert a schema to Zod

      1. Paste a JSON Schema on the left, open a file, or load one from your stash.
      2. Choose the options. The Zod code updates as you type.
      3. Copy it into your project or download it as a .ts file, then npm install zod if you have not already.

      Strings get .min(), .max(), .regex() and format checks such as .email(), .url(), .uuid(), .date() and .datetime(). Numbers get .int(), .gte(), .lt() and .multipleOf(). Optional properties get .optional(), additionalProperties: false becomes .strict(), and enums become z.enum() or literal unions.

      Options

      Export inferred types
      Adds export type User = z.infer<typeof UserSchema> after each schema.
      .describe() from descriptions
      Keeps each description as Zod metadata, which tools that turn Zod into JSON Schema or OpenAPI can read back.

      FAQ

      Which Zod versions does the output support?

      The generated code only uses APIs available in both Zod 3.23+ and Zod 4, such as z.string().email(), .datetime({ offset: true }), z.record(z.string(), …) and .catchall(). Some of them are marked deprecated in Zod 4 but still work.

      How are recursive schemas handled?

      Schemas are declared in dependency order. When definitions refer to each other in a cycle, references use z.lazy() and the cycle gets an explicit TypeScript type, because Zod cannot infer recursive types on its own.

      Is anything approximated?

      A few keywords have no direct Zod equivalent: patternProperties become .catchall() (or a record with a key pattern), uniqueItems becomes a refine() check, and not, if/then/else and minProperties are skipped. Notes appear under the output when that happens.