Skip to content
PithLab

↑↓ to move · Enter to open · Esc to close

JSON to Zod API

Generate Zod schemas (and inferred TypeScript types) from a sample JSON document, optionally detecting string formats such as email, URL, UUID and dates.

POST /api/v1/tools/json-to-zodMCP json_to_zodDeveloper Tools

Generate Zod schemas and z.infer types from a JSON sample, with nested schemas, nullable and optional keys, unions and optional email, URL, UUID and date checks.

Input

Send these as a JSON object. Unknown fields are rejected.

input
A sample JSON document (object or array). (string, required)
rootName
Name of the top-level type; the schema is named <rootName>Schema in camelCase. (string, up to 100 characters, default "Root")
detectFormats
Add .datetime(), .date(), .email(), .url() and .uuid() when every sample value matches. (boolean, default false)
exportTypes
Add `export type X = z.infer<typeof xSchema>` for each schema. (boolean, default true)
curl https://pithlab.com/api/v1/tools/json-to-zod \n  -H "Authorization: Bearer $PITHLAB_KEY" \n  -H "Content-Type: application/json" \n  -d '{"input":"{\"id\":\"3f2b8c1e-4d5a-4b6c-9e7f-1a2b3c4d5e6f\",\"email\":\"[email protected]\",\"age\":36}","rootName":"User","detectFormats":true}'
Example response
{
  "ok": true,
  "result": {
    "output": "import { z } from \"zod\";\n\nexport const userSchema = z.object({\n  id: z.string().uuid(),\n  email: z.string().email(),\n  age: z.number(),\n});\n"
  }
}