JSON Schema to TypeScript, Zod & Pydantic Converter Online

Convert JSON Schema to TypeScript, Zod or Pydantic, upgrade draft-04/06/07 to 2020-12, convert to and from OpenAPI 3.0, and bundle or dereference $ref.

Free tool: 20 requests per minute.

Result

Press “Run” to see the result.

Send a JSON Schema (object, JSON or YAML text, file or URL) and pick to. Code: typescript (interfaces / types with JSDoc), zod (schemas with min / max / regex / email / uuid / datetime refinements, .strict(), z.lazy for recursion, plus z.infer types) and pydantic (Pydantic v2 models with Field() constraints, aliases for non-identifier keys, extra="forbid"); definitions / $defs become named types.

Drafts: 2020-12, 2019-09, draft-07, draft-06, draft-04 upgrade or downgrade the schema (definitions ↔ $defs, id ↔ $id, boolean ↔ numeric exclusiveMinimum / Maximum, items array ↔ prefixItems, dependencies ↔ dependentRequired / dependentSchemas, const ↔ enum, keywords next to $ref). OpenAPI: openapi-3.0 turns JSON Schema into an OpenAPI 3.0 Schema Object (nullable, example, exclusive bounds, $defs → components.schemas); json-schema does the reverse and accepts a whole OpenAPI 3.0 (or Swagger 2.0) document. References: bundle pulls external $refs (from refs = {"common.json": {...}} or URLs with fetch=1) into $defs; dereference inlines every $ref and reports cycles (kept as $ref, or circular=error).

Whatever cannot be expressed in the target is listed in warnings. Related: /v1/json-to-types infers types from sample JSON, /v1/schema-mock makes example data, /v1/openapi-tools works on whole API documents. format=text returns only the code.

Use this in your code

curl -X POST "https://apibox.io.vn/v1/schema-convert" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"schema":{"title":"Order","type":"object","required":["id","items"],"properties":{"id":{"type":"string","format":"uuid"},"items":{"type":"array","minItems":1,"items":{"$ref":"#/$defs/Item"}},"note":{"type":["string","null"],"maxLength":500}},"$defs":{"Item":{"type":"object","required":["sku","qty"],"properties":{"sku":{"type":"string"},"qty":{"type":"integer","minimum":1}}}}},"to":"zod"}'

API documentation → Get a free API key

FAQ

Which Zod version is generated?

The Zod 3 API (z.object, z.string().email()…), which Zod 4 still accepts.

Can it convert TypeScript to JSON Schema?

No, that needs the TypeScript compiler. Use JSON Schema as the source, or infer from sample data with json-to-types.

What happens with external $ref?

Pass the referenced documents in refs, or set fetch=1 to download public http(s) URLs (up to 20 documents).