{"id":29290488,"url":"https://github.com/omermecitoglu/json-schema-to-zod","last_synced_at":"2026-01-20T17:31:28.853Z","repository":{"id":302877599,"uuid":"1013593298","full_name":"omermecitoglu/json-schema-to-zod","owner":"omermecitoglu","description":"Zod schema generator from JSON schema specs","archived":false,"fork":false,"pushed_at":"2025-07-26T08:15:36.000Z","size":105,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-26T12:19:59.594Z","etag":null,"topics":["generator","json-schema","zod"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/omermecitoglu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-07-04T06:42:36.000Z","updated_at":"2025-07-26T08:06:08.000Z","dependencies_parsed_at":"2025-07-04T15:23:37.150Z","dependency_job_id":"1b7673f2-f0cb-4855-93b3-d1baba0f4558","html_url":"https://github.com/omermecitoglu/json-schema-to-zod","commit_stats":null,"previous_names":["omermecitoglu/json-schema-to-zod"],"tags_count":5,"template":false,"template_full_name":"omermecitoglu/node-module","purl":"pkg:github/omermecitoglu/json-schema-to-zod","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omermecitoglu%2Fjson-schema-to-zod","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omermecitoglu%2Fjson-schema-to-zod/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omermecitoglu%2Fjson-schema-to-zod/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omermecitoglu%2Fjson-schema-to-zod/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/omermecitoglu","download_url":"https://codeload.github.com/omermecitoglu/json-schema-to-zod/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omermecitoglu%2Fjson-schema-to-zod/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269201304,"owners_count":24377461,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-07T02:00:09.698Z","response_time":73,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["generator","json-schema","zod"],"created_at":"2025-07-06T07:00:29.082Z","updated_at":"2026-01-20T17:31:28.839Z","avatar_url":"https://github.com/omermecitoglu.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# json-schema-to-zod\n\n[![npm version](https://img.shields.io/npm/v/@omer-x/json-schema-to-zod?logo=npm\u0026logoColor=CB3837\u0026color=CB3837)](https://www.npmjs.com/package/@omer-x/json-schema-to-zod)\n[![npm downloads](https://img.shields.io/npm/dm/@omer-x/json-schema-to-zod?logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA1MTIgNTEyIj48IS0tIUZvbnQgQXdlc29tZSBGcmVlIDYuNi4wIGJ5IEBmb250YXdlc29tZSAtIGh0dHBzOi8vZm9udGF3ZXNvbWUuY29tIExpY2Vuc2UgLSBodHRwczovL2ZvbnRhd2Vzb21lLmNvbS9saWNlbnNlL2ZyZWUgQ29weXJpZ2h0IDIwMjQgRm9udGljb25zLCBJbmMuLS0+PHBhdGggZD0iTTI4OCAzMmMwLTE3LjctMTQuMy0zMi0zMi0zMnMtMzIgMTQuMy0zMiAzMmwwIDI0Mi43LTczLjQtNzMuNGMtMTIuNS0xMi41LTMyLjgtMTIuNS00NS4zIDBzLTEyLjUgMzIuOCAwIDQ1LjNsMTI4IDEyOGMxMi41IDEyLjUgMzIuOCAxMi41IDQ1LjMgMGwxMjgtMTI4YzEyLjUtMTIuNSAxMi41LTMyLjggMC00NS4zcy0zMi44LTEyLjUtNDUuMyAwTDI4OCAyNzQuNyAyODggMzJ6TTY0IDM1MmMtMzUuMyAwLTY0IDI4LjctNjQgNjRsMCAzMmMwIDM1LjMgMjguNyA2NCA2NCA2NGwzODQgMGMzNS4zIDAgNjQtMjguNyA2NC02NGwwLTMyYzAtMzUuMy0yOC43LTY0LTY0LTY0bC0xMDEuNSAwLTQ1LjMgNDUuM2MtMjUgMjUtNjUuNSAyNS05MC41IDBMMTY1LjUgMzUyIDY0IDM1MnptMzY4IDU2YTI0IDI0IDAgMSAxIDAgNDggMjQgMjQgMCAxIDEgMC00OHoiIGZpbGw9IiMwMDc4MjAiIC8+PC9zdmc+\u0026color=007820)](https://www.npmjs.com/package/@omer-x/json-schema-to-zod)\n[![codecov](https://codecov.io/gh/omermecitoglu/json-schema-to-zod/branch/main/graph/badge.svg)](https://codecov.io/gh/omermecitoglu/json-schema-to-zod)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg?logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA2NDAgNTEyIj48IS0tIUZvbnQgQXdlc29tZSBGcmVlIDYuNi4wIGJ5IEBmb250YXdlc29tZSAtIGh0dHBzOi8vZm9udGF3ZXNvbWUuY29tIExpY2Vuc2UgLSBodHR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g5LjcgNDE2IDEyNi44IDQxNlMxMS43IDM4MiAuOSAzMzcuMXoiIGZpbGw9IiNEMEE4MUMiIC8+PC9zdmc+)](https://opensource.org/licenses/MIT)\n[![GitHub last commit](https://img.shields.io/github/last-commit/omermecitoglu/json-schema-to-zod?color=c977be\u0026logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA2NDAgNTEyIj48IS0tIUZvbnQgQXdlc29tZSBGcmVlIDYuNi4wIGJ5IEBmb250YXdlc29tZSAtIGh0dHBzOi8vZm9udGF3ZXNvbWUuY29tIExpY2Vuc2UgLSBodHRwczovL2ZvbnRhd2Vzb21lLmNvbS9saWNlbnNlL2ZyZWUgQ29weXJpZ2h0IDIwMjQgRm9udGljb25zLCBJbmMuLS0+PHBhdGggZD0iTTMyMCAzMzZhODAgODAgMCAxIDAgMC0xNjAgODAgODAgMCAxIDAgMCAxNjB6bTE1Ni44LTQ4QzQ2MiAzNjEgMzk3LjQgNDE2IDMyMCA0MTZzLTE0Mi01NS0xNTYuOC0xMjhMMzIgMjg4Yy0xNy43IDAtMzItMTQuMy0zMi0zMnMxNC4zLTMyIDMyLTMybDEzMS4yIDBDMTc4IDE1MSAyNDIuNiA5NiAzMjAgOTZzMTQyIDU1IDE1Ni44IDEyOEw2MDggMjI0YzE3LjcgMCAzMiAxNC4zIDMyIDMycy0xNC4zIDMyLTMyIDMybC0xMzEuMiAweiIgZmlsbD0iI0M5NzdCRSIgLz48L3N2Zz4=)](https://github.com/omermecitoglu/json-schema-to-zod/commits/main/)\n[![GitHub issues](https://img.shields.io/github/issues/omermecitoglu/json-schema-to-zod?color=a38eed\u0026logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxNiAxNiIgd2lkdGg9IjE2IiBoZWlnaHQ9IjE2Ij4KICA8cGF0aCBkPSJNOCA5LjVhMS41IDEuNSAwIDEgMCAwLTMgMS41IDEuNSAwIDAgMCAwIDNaIiBmaWxsPSIjQTM4RUVEIj48L3BhdGg+CiAgPHBhdGggZD0iTTggMGE4IDggMCAxIDEgMCAxNkE4IDggMCAwIDEgOCAwWk0xLjUgOGE2LjUgNi41IDAgMSAwIDEzIDAgNi41IDYuNSAwIDAgMC0xMyAwWiIgZmlsbD0iI0EzOEVFRCI+PC9wYXRoPgo8L3N2Zz4=)](https://github.com/omermecitoglu/json-schema-to-zod/issues)\n[![GitHub stars](https://img.shields.io/github/stars/omermecitoglu/json-schema-to-zod?style=social)](https://github.com/omermecitoglu/json-schema-to-zod)\n\n## Overview\n\n`json-schema-to-zod` is a TypeScript library that generates Zod schema code from JSON Schema specifications. It supports OpenAPI 3.x schemas and provides both runtime schema generation and TypeScript type definitions.\n\n## Features\n\n- Generate Zod schemas from JSON Schema objects\n- Support for OpenAPI 3.x specifications\n- Handles complex types: objects, arrays, unions, references\n- Type-safe generation with TypeScript\n- Lightweight and dependency-free (except peer dependencies)\n\n## Installation\n\nInstall the package using npm:\n\n```sh\nnpm install @omer-x/json-schema-to-zod\n```\n\n### Peer Dependencies\n\nThis package requires the following peer dependencies:\n\n- `zod`: ^4.0.0\n- `@omer-x/openapi-types`: ^1.0.0\n\nInstall them if not already present:\n\n```sh\nnpm install zod @omer-x/openapi-types\n```\n\n## Usage\n\n### Basic Example\n\n```typescript\nimport { generateZodSchema } from '@omer-x/json-schema-to-zod';\n\nconst jsonSchema = {\n  type: 'object',\n  properties: {\n    name: { type: 'string' },\n    age: { type: 'integer', minimum: 0 }\n  },\n  required: ['name']\n};\n\nconst result = generateZodSchema(jsonSchema);\nconsole.log(result.body); // \"z.object({ name: z.string(), age: z.int().min(0) })\"\n```\n\n### Using with References\n\n```typescript\nimport { generateZodSchema } from '@omer-x/json-schema-to-zod';\n\nconst schemaWithRef = {\n  $ref: '#/components/schemas/User'\n};\n\nconst result = generateZodSchema(schemaWithRef);\nconsole.log(result.body); // User\nconsole.log(result.dependencies); // ['User']\n```\n\n### Generating Type Definitions\n\n```typescript\nimport { generateZodType } from '@omer-x/json-schema-to-zod';\n\nconst jsonSchema = { type: 'string' };\nconst result = generateZodType(jsonSchema);\nconsole.log(result.body); // \"z.ZodString\"\n```\n\n## API Reference\n\n### `generateZodSchema(jsonSchema: SchemaObject | ReferenceObject): Definition`\n\nGenerates a Zod schema string from a JSON Schema object.\n\n- **Parameters:**\n  - `jsonSchema`: A JSON Schema object or reference object\n- **Returns:** A `Definition` object with:\n  - `body`: The generated Zod schema code\n  - `dependencies`: Array of referenced component names\n\n### `generateZodType(jsonSchema: SchemaObject): Definition`\n\nGenerates a Zod type definition string from a JSON Schema object.\n\n- **Parameters:**\n  - `jsonSchema`: A JSON Schema object\n- **Returns:** A `Definition` object with:\n  - `body`: The generated Zod type code\n  - `dependencies`: Array of referenced component names\n\n## Supported JSON Schema Features\n\n- Primitive types: `boolean`, `null`, `integer`, `number`, `string`\n- Objects with properties and required fields\n- Arrays with item schemas\n- Unions (`anyOf`, `oneOf`)\n- References (`$ref`)\n- String formats and constraints\n- Numeric constraints (min, max, etc.)\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.\n\n### Development\n\n1. Clone the repository\n2. Install dependencies: `npm install`\n3. Run tests: `npm test`\n4. Build the project: `npm run build`\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fomermecitoglu%2Fjson-schema-to-zod","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fomermecitoglu%2Fjson-schema-to-zod","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fomermecitoglu%2Fjson-schema-to-zod/lists"}