{"id":28779023,"url":"https://github.com/nexxtmove/json-schema-kit","last_synced_at":"2026-03-17T14:17:10.303Z","repository":{"id":298737107,"uuid":"1000934614","full_name":"nexxtmove/json-schema-kit","owner":"nexxtmove","description":"Some (very) simple helper functions to write JSON Schema more concisely","archived":false,"fork":false,"pushed_at":"2025-06-12T15:32:11.000Z","size":9,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-12T16:25:17.832Z","etag":null,"topics":["json-schema","openai","structured-output"],"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/nexxtmove.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-06-12T14:46:00.000Z","updated_at":"2025-06-12T15:35:16.000Z","dependencies_parsed_at":"2025-06-12T16:25:40.307Z","dependency_job_id":"c51ff123-95fa-4d0b-91af-802d30be16cd","html_url":"https://github.com/nexxtmove/json-schema-kit","commit_stats":null,"previous_names":["nexxtmove/json-schema-kit"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/nexxtmove/json-schema-kit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nexxtmove%2Fjson-schema-kit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nexxtmove%2Fjson-schema-kit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nexxtmove%2Fjson-schema-kit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nexxtmove%2Fjson-schema-kit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nexxtmove","download_url":"https://codeload.github.com/nexxtmove/json-schema-kit/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nexxtmove%2Fjson-schema-kit/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260406137,"owners_count":23004119,"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","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":["json-schema","openai","structured-output"],"created_at":"2025-06-17T17:01:13.759Z","updated_at":"2026-03-17T14:17:10.291Z","avatar_url":"https://github.com/nexxtmove.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🧰 JSON Schema Kit\n\nSome [very simple](https://github.com/nexxtmove/json-schema-kit/blob/main/src/index.ts) helper functions for writing concise JSON Schema — perfect for [OpenAI Structured Outputs](https://platform.openai.com/docs/guides/structured-outputs).\n\n\u003ca href=\"https://www.npmjs.com/package/json-schema-kit\" target=\"_blank\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/json-schema-kit?style=flat-square\u0026color=%234c1\" alt=\"Version\"\u003e\u003c/a\u003e\n\u003ca href=\"https://www.npmjs.com/package/json-schema-kit\" target=\"_blank\"\u003e\u003cimg src=\"https://img.shields.io/npm/l/json-schema-kit?style=flat-square\u0026color=%234c1\" alt=\"License\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/nexxtmove/json-schema-kit/actions\" target=\"_blank\"\u003e\u003cimg src=\"https://img.shields.io/github/actions/workflow/status/nexxtmove/json-schema-kit/tests.yml?label=tests\u0026style=flat-square\u0026color=%234c1\" alt=\"Tests\"\u003e\u003c/a\u003e\n\n## ✨ Quick Taste\n\n```ts\nimport { object, string, number, array, nullable } from 'json-schema-kit'\n\nobject({\n  name: string(),\n  price: number({ minimum: 0 }),\n  description: nullable(string()),\n  categories: array(string()),\n})\n```\n\n\u003e All functions just return plain JavaScript objects. Freely modify or extend them to fit your needs.\n\n## 🚀 Installation\n\n```bash\nnpm install json-schema-kit\n```\n\n## 🆚 Comparison\n\n\u003cdetails\u003e\n\n\u003csummary\u003eTraditional JSON Schema\u003c/summary\u003e\n\n```json\n{\n  \"type\": \"object\",\n  \"properties\": {\n    \"name\": { \"type\": \"string\" },\n    \"price\": { \"type\": \"number\", \"description\": \"Price in dollars\" },\n    \"discount\": { \"anyOf\": [{ \"type\": \"number\" }, { \"type\": \"null\" }] },\n    \"categories\": { \"type\": \"array\", \"items\": { \"type\": \"string\", \"enum\": [\"electronics\", \"clothing\", \"books\"] } },\n    \"dimensions\": {\n      \"type\": \"object\",\n      \"properties\": {\n        \"width\": { \"type\": \"number\" },\n        \"height\": { \"type\": \"number\" }\n      },\n      \"required\": [\"width\", \"height\"],\n      \"additionalProperties\": false\n    }\n  },\n  \"required\": [\"name\", \"price\", \"discount\", \"categories\", \"dimensions\"],\n  \"additionalProperties\": false\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\n\u003csummary\u003eUsing JSON Schema Kit\u003c/summary\u003e\n\n```ts\nobject({\n  name: string(),\n  price: number({ description: 'Price in dollars' }),\n  discount: nullable(number()),\n  categories: array(string({ enum: ['electronics', 'clothing', 'books'] })),\n  dimensions: object({\n    width: number(),\n    height: number(),\n  }),\n})\n```\n\n\u003c/details\u003e\n\n## 🤖 OpenAI Structured Outputs\n\nJSON Schema Kit is perfectly suited for OpenAI's Structured Outputs.  \nFor example, here's how to use it with the Vercel AI SDK:\n\n```ts\nconst schema = object({\n  summary: string(),\n  sentiment: string({ enum: ['positive', 'neutral', 'negative'] }),\n})\n\nawait generateObject({\n  model: openai(...),\n  schema: jsonSchema(schema),\n  prompt: 'Analyze this review: \"Great product, works perfectly!\"',\n})\n```\n\n## 🔗 Using References\n\nUse `$ref` to create reusable schema definitions and reference them throughout your schema:\n\n```ts\nconst person = object({\n  name: string(),\n  age: number(),\n})\n\nconst team = object({\n  leader: $ref('person'),\n  members: array($ref('person')),\n})\n\nteam.$defs = { person }\n```\n\n\u003e Read more about `$ref` and `$defs` in the [JSON Schema Documentation](https://json-schema.org/understanding-json-schema/structuring#dollarref)\n\n## 🔀 Using Union Types\n\nCreate union types using `anyOf` to allow multiple possible schemas:\n\n```ts\nconst contact = anyOf([\n  object({ email: string() }),\n  object({ phone: string() }),\n])\n```\n\n\u003e Read more about `anyOf` in the [JSON Schema Documentation](https://json-schema.org/understanding-json-schema/reference/combining#anyOf)\n\n## 🤔 \"But what about Zod?\"\n\nGreat question! Zod is a versatile and comprehensive library, spanning thousands of lines of code. However, it's not specifically built for generating JSON Schemas, which can lead to unexpected results during conversion. In contrast, JSON Schema Kit provides full control — all in under 100 lines of code.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnexxtmove%2Fjson-schema-kit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnexxtmove%2Fjson-schema-kit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnexxtmove%2Fjson-schema-kit/lists"}