
Company News
Free Business Plan Upgrades for Open Source Maintainers
Open source maintainers are under more pressure than ever. We're raising our open source program from the Team plan to the Business plan, free.
@trigger.dev/schema-to-json
Advanced tools
Convert various schema validation libraries to JSON Schema
Convert various schema validation libraries to JSON Schema format.
npm install @trigger.dev/schema-to-json
This package is designed to be bundle-safe. It does NOT bundle any schema libraries (zod, yup, etc.) as dependencies. Instead:
This design ensures that:
toJsonSchema method (no external deps needed)zod-to-json-schema to be installed@sodaru/yup-to-json-schema to be installedtoJsonSchema method)effect or @effect/schema to be installedimport { schemaToJsonSchema } from '@trigger.dev/schema-to-json';
import { type } from 'arktype';
// Works immediately for schemas with built-in conversion
const arkSchema = type({
name: 'string',
age: 'number',
});
const result = schemaToJsonSchema(arkSchema);
console.log(result);
// { jsonSchema: {...}, schemaType: 'arktype' }
import { schemaToJsonSchema, initializeSchemaConverters } from '@trigger.dev/schema-to-json';
import { z } from 'zod';
// Initialize converters once in your app (loads conversion libraries if available)
await initializeSchemaConverters();
// Now you can convert Zod 3, Yup, and Effect schemas
const zodSchema = z.object({
name: z.string(),
age: z.number(),
email: z.string().email(),
});
const result = schemaToJsonSchema(zodSchema);
console.log(result);
// {
// jsonSchema: {
// type: 'object',
// properties: {
// name: { type: 'string' },
// age: { type: 'number' },
// email: { type: 'string', format: 'email' }
// },
// required: ['name', 'age', 'email']
// },
// schemaType: 'zod'
// }
schemaToJsonSchema(schema, options?)Convert a schema to JSON Schema format.
Parameters:
schema - The schema to convertoptions (optional)
name - Name to use for the schema (supported by some converters)additionalProperties - Additional properties to merge into the resultReturns:
{ jsonSchema, schemaType } - The converted JSON Schema and detected typeundefined - If the schema cannot be convertedinitializeSchemaConverters()Initialize the external conversion libraries. Call this once in your application if you need to convert schemas that don't have built-in JSON Schema support (Zod 3, Yup, Effect).
Returns: Promise<void>
canConvertSchema(schema)Check if a schema can be converted to JSON Schema.
Returns: boolean
detectSchemaType(schema)Detect the type of schema.
Returns: 'zod' | 'yup' | 'arktype' | 'effect' | 'valibot' | 'superstruct' | 'runtypes' | 'typebox' | 'unknown'
areConvertersInitialized()Check which conversion libraries are available.
Returns: { zod: boolean, yup: boolean, effect: boolean }
Each schema library is an optional peer dependency. Install only the ones you need:
# For Zod
npm install zod
# For Yup
npm install yup
# For ArkType
npm install arktype
# For Effect
npm install effect @effect/schema
# For TypeBox
npm install @sinclair/typebox
MIT
FAQs
Convert various schema validation libraries to JSON Schema
The npm package @trigger.dev/schema-to-json receives a total of 337,193 weekly downloads. As such, @trigger.dev/schema-to-json popularity was classified as popular.
We found that @trigger.dev/schema-to-json demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Open source maintainers are under more pressure than ever. We're raising our open source program from the Team plan to the Business plan, free.

Security News
The supply chain control that delays freshly published gems now covers lockfile generation and gem vendoring in Ruby projects.

Security News
During a UK cyber test, a Mythos 5 agent used sockpuppets, social engineering, and prompt injection to try to get a maintainer to merge malware.