{"id":48300,"library":"json-schema-to-zod-v3","title":"json-schema-to-zod-v3","description":"A TypeScript library for converting JSON Schema (Draft 7+) to Zod v3 validation schemas. Current version 1.0.4, compatible with Zod ^3.0.0. Differentiators include built-in ReDoS protection for regex patterns, full type safety, zero runtime dependencies (only peer dependency on Zod), and coverage of all major JSON Schema features. The library uses a security configuration system with default protection against malicious patterns, and provides both high-level conversion and low-level utility functions.","status":"active","version":"1.0.4","language":"javascript","source_language":"en","source_url":"https://github.com/agentfront/frontmcp","tags":["javascript","json-schema","zod","zod-v3","validation","schema","converter","typescript","json-schema-to-zod"],"install":[{"cmd":"npm install json-schema-to-zod-v3","lang":"bash","label":"npm"},{"cmd":"yarn add json-schema-to-zod-v3","lang":"bash","label":"yarn"},{"cmd":"pnpm add json-schema-to-zod-v3","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency – generates Zod schemas; requires Zod v3 installed alongside.","package":"zod","optional":false}],"imports":[{"note":"This is a named export, not a default export. Using default import will fail.","wrong":"import convertJsonSchemaToZod from 'json-schema-to-zod-v3';","symbol":"convertJsonSchemaToZod","correct":"import { convertJsonSchemaToZod } from 'json-schema-to-zod-v3';"},{"note":"Available as a named export; no default export for this function.","wrong":null,"symbol":"setSecurityConfig","correct":"import { setSecurityConfig } from 'json-schema-to-zod-v3';"},{"note":"Utility function for manual pattern validation; also a named export.","wrong":null,"symbol":"validatePattern","correct":"import { validatePattern } from 'json-schema-to-zod-v3';"},{"note":"Creates a RegExp with timeout; named export.","wrong":null,"symbol":"createSafeRegExp","correct":"import { createSafeRegExp } from 'json-schema-to-zod-v3';"}],"quickstart":{"code":"import { convertJsonSchemaToZod } from 'json-schema-to-zod-v3';\nimport { z } from 'zod';\n\nconst jsonSchema = {\n  type: 'object',\n  properties: {\n    name: { type: 'string', minLength: 1 },\n    age: { type: 'number', minimum: 0, maximum: 120 },\n    email: { type: 'string', pattern: '^[^@]+@[^@]+\\.[^@]+$' },\n  },\n  required: ['name', 'email'],\n};\n\nconst zodSchema = convertJsonSchemaToZod(jsonSchema);\n\nconst result = zodSchema.safeParse({\n  name: 'John Doe',\n  email: 'john@example.com',\n  age: 30,\n});\n\nconsole.log(result.success); // true","lang":"typescript","description":"Converts a JSON Schema object to a Zod v3 schema and validates sample data, showing full type safety and usage of safeParse."},"warnings":[{"fix":"Ensure your JSON Schema conforms to Draft 7+.","message":"The library only supports JSON Schema Draft 7+. Earlier drafts may produce incorrect results.","severity":"gotcha","affected_versions":"<1.0.0"},{"fix":"Track release notes for migration; consider wrapping calls in a configuration object.","message":"The `setSecurityConfig` function modifies global state. Future versions may remove this in favor of per-call configuration.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Disable or customize protection using `setSecurityConfig({ enableProtection: false })` if you trust your input.","message":"ReDoS protection is enabled by default. Patterns exceeding 1000 characters or with nested quantifiers will cause conversion to fail without explicit configuration.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Always check the return value: `const regex = createSafeRegExp(pattern); if (!regex) { /* handle unsafe */ }`","message":"The `createSafeRegExp` function returns `null` for unsafe patterns, unlike standard RegExp constructor which throws. Code assuming it always returns a RegExp will break.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Switch to named imports: `import { convertJsonSchemaToZod } from 'json-schema-to-zod-v3'`","message":"Version 1.0.0 changed from default export to named exports. Code using `import J2Z from 'json-schema-to-zod-v3'` will break.","severity":"breaking","affected_versions":"<1.0.0"}],"env_vars":null,"search_vec":"'1.0.4':23 '3.0.0':27 '7':15 'built':31 'built-in':30 'compat':24 'configur':62 'convers':76 'convert':11,93 'coverag':50 'current':21 'default':65 'depend':43,46 'differenti':28 'draft':14 'featur':56 'full':38 'function':82 'high':74 'high-level':73 'includ':29 'javascript':83 'json':2,12,54,85,96 'json-schema':84 'json-schema-to-zod':95 'json-schema-to-zod-v3':1 'level':75,80 'librari':9,58 'low':79 'low-level':78 'major':53 'malici':68 'pattern':37,69 'peer':45 'protect':34,66 'provid':71 'redo':33 'regex':36 'runtim':42 'safeti':40 'schema':3,13,20,55,86,92,97 'secur':61 'system':63 'type':39 'typescript':8,94 'use':59 'util':81 'v3':6,18,90 'valid':19,91 'version':22 'zero':41 'zod':5,17,26,48,87,89,99 'zod-v3':88","created_at":"2026-06-07T16:55:56.424984+00:00","updated_at":"2026-06-07T16:55:56.424984+00:00","problems":[{"fix":"Use named import: `import { convertJsonSchemaToZod } from 'json-schema-to-zod-v3'`","cause":"Attempted to import the default export, but the library only provides named exports.","error":"TypeError: convertJsonSchemaToZod is not a function"},{"fix":"Either simplify the pattern or disable protection: `setSecurityConfig({ enableProtection: false })`","cause":"The JSON Schema contains a regex pattern with nested quantifiers (e.g., `(a+)+`) that fails the built-in ReDoS protection.","error":"Error: Pattern is unsafe: nested quantifier detected"},{"fix":"Install Zod: `npm install zod@^3.0.0`","cause":"The peer dependency `zod` is not installed.","error":"Error: Cannot find module 'zod'"},{"fix":"Ensure the input is a valid JSON Schema object: `convertJsonSchemaToZod({ type: 'string' })`","cause":"Passed a non-object (e.g., string, number) as the JSON Schema input.","error":"TypeError: JSON Schema is not an object"},{"fix":"Increase the limit: `setSecurityConfig({ maxPatternLength: 2000 })` or reduce pattern length.","cause":"Pattern length exceeds 1000 characters (default limit).","error":"Warning: Pattern exceeds max length..."}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/agentfront/frontmcp/blob/main/libs/json-schema-to-zod-v3/README.md","github":"https://github.com/agentfront/frontmcp","docs":null,"changelog":null,"pypi":null,"npm":"json-schema-to-zod-v3","openapi_spec":null,"status_page":null,"smithery":null,"categories":["validation"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}