Registry / database / xsschema

xsschema

JSON →
library0.5.0-beta.5jsnpmunverified

xsschema is an extra-small, Standard Schema-based alternative to typeschema, providing a unified schema validation layer for multiple validation libraries (Zod, ArkType, Effect, Valibot) with JSON Schema generation. Current version is 0.5.0-beta.5 (pre-release). It has no release cadence yet. Key differentiators: standardized adapter interface (Standard Schema), lightweight footprint, and seamless integration with the xsai ecosystem. Ships TypeScript types.

npm install xsschema
INSTALL
IMPORT
SIG · XSSCHEMA
X
xsschema
databasejavascriptv0.5.0-beta.5
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

xsschema
import { xsschema } from 'xsschema'
const xsschema = require('xsschema')
ESM-only package; use dynamic import or bundler for CJS projects.
type Infer
import { type Infer } from 'xsschema'
import { Infer } from 'xsschema'
Use type import for TypeScript to avoid runtime import.
createSchemaAdapter
import { createSchemaAdapter } from 'xsschema'
Factory function to create an adapter for a specific validator.
jsonSchema
import { jsonSchema } from 'xsschema'
import { toJsonSchema } from 'xsschema'
Not exported as 'toJsonSchema'; use 'jsonSchema' helper.

Creates a Zod schema, converts it to JSON Schema using xsschema, and parses an object with the adapter.

import { xsschema } from 'xsschema'; import { z } from 'zod'; const schema = z.object({ name: z.string(), age: z.number() }); const jsonSchema = xsschema.toJSON(schema); console.log(jsonSchema); const adapter = xsschema.getAdapter(schema); const result = adapter.parse({ name: 'Alice', age: 30 }); console.log(result);
Debug
Known issues
breakingThe package is in beta; API may change without notice.
fix
Pin to a specific version and test after upgrade.
affects: >=0.5.0
gotchaxsschema requires a validator library (Zod, ArkType, etc.) to be installed; it is not standalone.
fix
Ensure at least one peer dependency is installed.
affects: all
deprecatedtypeschema adapter is no longer supported; use xsschema directly.
fix
Replace typeschema usage with xsschema's equivalent API.
affects: >=0.5.0
Errors
Common errors & fixes
Cannot find module 'xsschema' or its corresponding type declarations.
Missing installation or TypeScript not resolving the package.
fix
Run 'npm install xsschema' and ensure tsconfig.json has 'moduleResolution': 'node16' or 'bundler'.
TypeError: xsschema.toJSON is not a function
The export name is incorrect; 'toJSON' does not exist as a method.
fix
Use 'xsschema.toJSONSchema' or check documentation for the correct method name.
Cannot read properties of undefined (reading 'parse')
The adapter for the schema type is not registered or the schema is invalid.
fix
Verify that the schema is created with a supported validator (e.g., Zod) and that the corresponding adapter is installed.
Upgrade
Version history
0.5.0-beta.5latest on npm
Audit
Dependencies
@valibot/to-json-schemaoptionalConverts Valibot schemas to JSON Schema
arktypeoptionalIntegration with ArkType validation library
effectoptionalIntegration with Effect schema validator
suryoptionalIntegration with sury validation library
zodoptionalIntegration with Zod validation library
zod-to-json-schemaoptionalConverts Zod schemas to JSON Schema
Agent activity
29 hits · last 30 days
node
24
Meta
2
OpenAI (training)
1
Resources
xsschema — npm install xsschema · libregistry