[](https://npmjs.org/package/@standard-community/standard-json "View this project on NPM") [
npm install @kingbri1/standard-json


Standard Schema Validator's JSON Schema Converter
Install the main package -
``sh`
pnpm add @standard-community/standard-json
For some specific vendor, install the respective package also -
| Vendor | Package |
| ------- | ------- |
| Zod | zod-to-json-schema |@valibot/to-json-schema
| Valibot | |
`ts
import { toJsonSchema } from "@standard-community/standard-json";
// Define your schema
const schema = v.pipe(
v.object({
myString: v.string(),
myUnion: v.union([v.number(), v.boolean()]),
}),
v.description("My neat object schema"),
);
// Convert it to JSON Schema
const jsonSchema = await toJsonSchema(schema);
``
List of supported validators -
| Vendor | Supported |
| ------- | ------- |
| Zod | ✅ |
| Valibot | ✅ |
| ArkType | ✅ |
| Typebox | ✅ (Using TypeMap |
| Effect Schema | 🛠️ |
You can check the compatibility versions at standardschema.dev
- This project is inspired by the work of kwaa and their xsschema package.