☰
Home
/
Code Generators
/
JSON → Zod
Z
JSON → Zod
Generate Zod schema from JSON
☆
Bookmark
Loading tool…
JSON input
{ "id": 1, "name": "Ada Lovelace", "email": "ada@example.com", "isActive": true, "score": 98.6, "tags": ["admin", "developer"], "address": { "street": "123 Main St", "city": "London" }, "orders": [{ "id": 101, "total": 49.99, "shipped": false }] }
Zod output
⧉ Copy
import { z } from "zod"; export const addressSchema = z.object({ street: z.string(), city: z.string(), }); export type Address = z.infer<typeof addressSchema>; export const orderSchema = z.object({ id: z.number().int(), total: z.number(), shipped: z.boolean(), }); export type Order = z.infer<typeof orderSchema>; export const rootSchema = z.object({ id: z.number().int(), name: z.string(), email: z.string(), isActive: z.boolean(), score: z.number(), tags: z.array(z.string()), address: z.object({ street: z.string(), city: z.string(), }), orders: z.array(z.object({ id: z.number().int(), total: z.number(), shipped: z.boolean(), })), }); export type Root = z.infer<typeof rootSchema>;