Zod ↔ ArkType bidirectional transformer for SchemaShift
npm install @schemashift/zod-arktypeZod ↔ ArkType transformer for SchemaShift. Supports both forward (Zod → ArkType) and backward (ArkType → Zod) migrations.




Tier: Pro+
``bash`
npm install @schemashift/zod-arktype
`typescript
import { createZodToArktypeHandler, createArktypeToZodHandler } from '@schemashift/zod-arktype';
import { TransformEngine } from '@schemashift/core';
const engine = new TransformEngine();
engine.registerHandler('zod', 'arktype', createZodToArktypeHandler());
engine.registerHandler('arktype', 'zod', createArktypeToZodHandler()); // Backward migration (Pro+)
`
Zod uses a method chain API:
`typescript`
z.object({ name: z.string().email(), age: z.number().int() })
ArkType uses a TypeScript-like string API:
`typescript`
type({ name: "string.email", age: "number.integer" })
| Zod | ArkType |
|-----|---------|
| import { z } from 'zod' | import { type } from 'arktype' |
| Zod | ArkType |
|-----|---------|
| z.string() | "string" |z.number()
| | "number" |z.boolean()
| | "boolean" |z.bigint()
| | "bigint" |z.date()
| | "Date" |z.unknown()
| | "unknown" |z.never()
| | "never" |z.null()
| | "null" |z.void()
| | "void" |z.any()
| | "unknown" |z.object({...})
| | type({...}) |z.array(s)
| | "s[]" |z.enum(["a", "b"])
| | type("'a' \| 'b'") |z.literal(42)
| | type("=== 42") |z.union([a, b])
| | type("a \| b") |z.record(k, v)
| | type("Record |
| Zod | ArkType |
|-----|---------|
| z.string().email() | "string.email" |z.string().url()
| | "string.url" |z.string().uuid()
| | "string.uuid" |z.string().ip()
| | "string.ip" |z.number().int()
| | "number.integer" |
| Zod | ArkType |
|-----|---------|
| .optional() | "type?" |.nullable()
| | "type \| null" |
| Zod | ArkType |
|-----|---------|
| z.infer | typeof s.infer |z.input
| | typeof s.in |z.output
| | typeof s.infer |
ArkType uses .narrow() for refinements:
`typescript
// Zod
z.string().refine((s) => s.length > 0, "Required");
// ArkType
type("string").narrow((s) => s.length > 0);
`
ArkType uses morphs via .pipe():
`typescript
// Zod
z.string().transform((s) => s.toUpperCase());
// ArkType
type("string").pipe((s) => s.toUpperCase());
`
ArkType uses scope() for recursive definitions:
`typescript
// Zod
const node: z.ZodType
// ArkType
const types = scope({ node: { children: "node[]" } }).export();
`
ArkType has no .brand()` equivalent. Use nominal types or tagged unions instead.
- schemashift-cli — CLI tool for running migrations
- @schemashift/core — Core analysis engine
- @schemashift/zod-valibot — Zod ↔ Valibot transformer
MIT