
Product
Socket Firewall Now Blocks Malicious VS Code and Open VSX Extensions
Socket Firewall blocks malicious VS Code and Open VSX extensions before install, protecting developers from compromised editor marketplaces.
@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 223,829 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 5 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.

Product
Socket Firewall blocks malicious VS Code and Open VSX extensions before install, protecting developers from compromised editor marketplaces.

Research
More than 140 Mastra npm packages were compromised in a supply chain attack that used a typosquatted dependency to deliver a cross-platform infostealer during installation.

Research
/Security News
A new npm package tests AI malware scanners with prompt injection, safety-triggering comments, context flooding, and obfuscated JavaScript.