n8n/packages/@n8n/json-schema-to-zod
n8n-assistant[bot] 6336f0a447
🚀 Release 2.18.0 (#28768)
Co-authored-by: Matsuuu <16068444+Matsuuu@users.noreply.github.com>
2026-04-21 08:58:38 +00:00
..
src chore: Upgrade LangChain packages to latest versions (no-changelog) (#11771) 2024-12-02 15:35:23 +01:00
test chore: Migrate @n8n/json-schema-to-zod from Jest to Vitest (#28411) 2026-04-20 13:07:50 +00:00
.gitignore feat: Add fork of json-schema-to-zod (no-changelog) (#11228) 2024-10-17 15:57:44 +03:00
.npmignore feat: Add fork of json-schema-to-zod (no-changelog) (#11228) 2024-10-17 15:57:44 +03:00
eslint.config.mjs build: Update ESLint to v9 (#16639) 2025-06-27 10:42:47 +02:00
LICENSE feat: Add fork of json-schema-to-zod (no-changelog) (#11228) 2024-10-17 15:57:44 +03:00
package.json 🚀 Release 2.18.0 (#28768) 2026-04-21 08:58:38 +00:00
postcjs.cjs build: Update ESLint to v9 (#16639) 2025-06-27 10:42:47 +02:00
postesm.cjs build: Update ESLint to v9 (#16639) 2025-06-27 10:42:47 +02:00
README.md feat: Add fork of json-schema-to-zod (no-changelog) (#11228) 2024-10-17 15:57:44 +03:00
tsconfig.cjs.json refactor: Upgrade to TypeScript 6.0.2 (#27673) 2026-04-01 11:03:37 +00:00
tsconfig.esm.json refactor: Upgrade to TypeScript 6.0.2 (#27673) 2026-04-01 11:03:37 +00:00
tsconfig.json chore: Migrate @n8n/json-schema-to-zod from Jest to Vitest (#28411) 2026-04-20 13:07:50 +00:00
tsconfig.types.json refactor: Upgrade to TypeScript 6.0.2 (#27673) 2026-04-01 11:03:37 +00:00
vite.config.ts chore: Migrate @n8n/json-schema-to-zod from Jest to Vitest (#28411) 2026-04-20 13:07:50 +00:00

Json-Schema-to-Zod

A package to convert JSON schema (draft 4+) objects into Zod schemas in the form of Zod objects at runtime.

Installation

npm install @n8n/json-schema-to-zod

Simple example

import { jsonSchemaToZod } from "json-schema-to-zod";

const jsonSchema = {
  type: "object",
  properties: {
    hello: {
      type: "string",
    },
  },
};

const zodSchema = jsonSchemaToZod(myObject);

Overriding a parser

You can pass a function to the overrideParser option, which represents a function that receives the current schema node and the reference object, and should return a zod object when it wants to replace a default output. If the default output should be used for the node just return undefined.

Acknowledgements

This is a fork of json-schema-to-zod.