xschema

ArkType

Generate ArkType schemas from JSON Schema definitions

The ArkType adapter converts JSON Schema definitions into ArkType validation schemas with full TypeScript type inference.

Overview

  • Package: @xschemadev/arktype
  • Peer Dependency: arktype ^2.0.0
  • Compliance: 100%

ArkType is a TypeScript-native validation library with a unique syntax that mirrors TypeScript's type syntax. The xschema ArkType adapter generates native ArkType schemas from JSON Schema with:

  • 100% compliance with JSON Schema Test Suite (all supported drafts)
  • Full type inference - generated schemas include TypeScript types
  • Runtime validation - validate data with detailed error messages
  • Type-level validation - errors are surfaced at compile time where possible

Installation

bun add @xschemadev/arktype arktype
npm install @xschemadev/arktype arktype
pnpm add @xschemadev/arktype arktype
yarn add @xschemadev/arktype arktype

Usage

user.xschema.jsonc
{
  "$schema": "https://xschema.dev/schemas/typescript.jsonc",
  "schemas": [
    {
      "id": "User",
      "adapter": "@xschemadev/arktype",
      "source": "./user.schema.json"
    }
  ]
}
import {  } from "./client";

const user = ("User")({ : "1", : "Alice", : "alice@example.com" });
const user: {
    id: string;
    name: string | undefined;
    email: string;
}

See the TypeScript guide for full setup instructions.

Supported Features

The ArkType adapter has 100% compliance across all JSON Schema drafts. All tests pass.

See the Compliance page for the full breakdown by draft.

On this page