Converts Joi validation objects to JSON Schema (draft-04) for compatibility with tools that consume JSON Schema. Version 5.1.0 is the latest stable release, maintained on GitHub under Mozilla Foundation, but sees infrequent updates. It provides best-effort conversion with support for Joi's conditional forms via oneOf clauses. Key differentiator: minimal dependency, no runtime Joi execution, and optional transformer function for post-processing. Suitable for migrating Joi schemas to JSON Schema-based validators.
npm install joi-to-json-schemaNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Converts a Joi schema with required fields, defaults, regex, and conditionals to JSON Schema (draft-04).
Use a JSON Schema converter like @stoplight/spectral to upgrade the schema to a later draft.
Review the output oneOf clauses to ensure they meet your validation requirements.
Manually define JSON Schema for unsupported Joi types or contribute support upstream.
Inspected output and manually adjust if needed.
Upgrade Joi to a version that has the .describe() method (Joi >=10).
Ensure the first argument to convert() is a valid Joi schema object.
Refine Joi schema to use specific types (string, number, etc.) wherever possible.