Wapgee Logowapgee

Tools / JSON Schema → TypeScript / Zod

JSON Schema → TypeScript & Zod

Paste a JSON Schema from an API spec or config contract and get a TypeScript interface plus a Zod schema you can copy into your project. Everything runs in the browser — nothing is uploaded.

JSON Schema
// Numeric/string/array bounds (minLength, minimum, …) are enforced in Zod only.

export interface Audit {
  at: string;
  by?: string;
}
export interface Address {
  city: string;
  country?: string | null;
  tags?: string[];
}
export interface Root {
  /** Stable user id */
  id: string;
  email: string;
  displayName?: string;
  age?: number;
  status?: "active" | "invited" | "disabled";
  roles: "admin" | "editor" | "viewer"[];
  address?: Address;
  metadata?: {
  [key: string]: string;
};
  nickname?: string | null;
  audit?: Audit;
}

From contract to typed validators

JSON Schema is the lingua franca of API contracts, form builders, and config files. TypeScript describes the shape in your editor; Zod validates it at runtime. This free converter walks a schema once and emits both, so optional fields, enums, nested objects, arrays, and internal $refs stay consistent across outputs.

How schema keywords map to Zod

JSON SchemaZod output
type: object + propertiesz.object({...}); optional keys use .optional()
type: integerz.number().int()
enum: ["a","b"]z.enum(["a","b"])
type: ["string","null"] / nullable.nullable()
format: email|uuid|uri|date-time.email(), .uuid(), .url(), .datetime()
additionalProperties: false.strict()
Circular $refz.lazy(() => …)
minLength / minimum / minItemsZod .min() / .max() chains (TS ignores bounds)

Need to reshape JSON or YAML payloads instead of schemas? Use the JSON ⇄ YAML ⇄ TypeScript converter.

FAQ

Which JSON Schema drafts are supported?

The converter targets the common draft-07 subset and tolerates 2020-12 documents. Supported highlights include objects, arrays/tuples, enums, const, oneOf/anyOf/allOf, nullable, formats, constraints, descriptions, and internal $refs. External $refs, if/then/else, patternProperties, and not are ignored with a notice.

Is my schema uploaded anywhere?

No. Parsing and codegen run entirely in your browser. The last input and options are kept in localStorage on your device only so a refresh does not wipe your work.

Which Zod version is the output for?

Generated schemas use Zod 4-style APIs (z.object, .optional, .nullable, .strict, z.lazy, z.infer, and format helpers like .email() / .uuid()). Adjust imports if your project pins an older major.

What about OpenAPI schemas?

OpenAPI component schemas that look like JSON Schema objects often work, including nullable: true. Full OpenAPI documents are not expanded — paste the schema object (or $defs / components.schemas entry) you care about.

JSON Schema to TypeScript & Zod Converter — Free, In-Browser