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.
npm install json-schema-to-zod-v3No compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Converts a JSON Schema object to a Zod v3 schema and validates sample data, showing full type safety and usage of safeParse.
Ensure your JSON Schema conforms to Draft 7+.
Track release notes for migration; consider wrapping calls in a configuration object.
Disable or customize protection using `setSecurityConfig({ enableProtection: false })` if you trust your input.Always check the return value: `const regex = createSafeRegExp(pattern); if (!regex) { /* handle unsafe */ }`Switch to named imports: `import { convertJsonSchemaToZod } from 'json-schema-to-zod-v3'`Use named import: `import { convertJsonSchemaToZod } from 'json-schema-to-zod-v3'`Either simplify the pattern or disable protection: `setSecurityConfig({ enableProtection: false })`Install Zod: `npm install zod@^3.0.0`
Ensure the input is a valid JSON Schema object: `convertJsonSchemaToZod({ type: 'string' })`Increase the limit: `setSecurityConfig({ maxPatternLength: 2000 })` or reduce pattern length.