JSON to Zod Schema Generator

Paste a JSON sample and get a Zod schema that validates it at runtime. Use z.infer on the schema to get the TypeScript type as well.

Example

Input
{
  "name": "parsebox",
  "version": "2.1.0",
  "private": false,
  "maintainers": [
    { "name": "Ada Lovelace", "email": "[email protected]", "active": true },
    { "name": "Alan Turing", "email": "[email protected]", "active": false }
  ],
  "build": {
    "target": "es2022",
    "minify": true,
    "port": 5173
  }
}
Output
import { z } from "zod";

export const MaintainerSchema = z.object({
  name: z.string(),
  email: z.string(),
  active: z.boolean(),
});
export type Maintainer = z.infer<typeof MaintainerSchema>;

export const BuildSchema = z.object({
  target: z.string(),
  minify: z.boolean(),
  port: z.number().int(),
});
export type Build = z.infer<typeof BuildSchema>;

export const RootSchema = z.object({
  name: z.string(),
  version: z.string(),
  private: z.boolean(),
  maintainers: z.array(MaintainerSchema),
  build: BuildSchema,
});
export type Root = z.infer<typeof RootSchema>;

Private by design

ParseBox runs entirely in your browser. Your text is never uploaded, logged or stored on a server, so it is safe to paste API responses, tokens and config files.

Related conversions

All 30 formats in ParseBox →