ArkType

Community projects built on ArkType, for environment variables, Drizzle codegen and binary serialization.

These projects are maintained by their authors, not the ArkType team. For libraries that accept a Type directly, see Integrations.

ArkEnv

ArkEnv validates your environment variables with an ArkType definition and gives you a typed env object, with strings like "3000" already parsed into the types you declared.

It works like T3 Env, built around ArkType definitions, and adds keywords for common variables like string.host and number.port.

Scaffold with npx arkenv init and import from @arkenv/core (arkenv on npm is the CLI).

@arkenv/core 1.0.0-rc.4 is written for ArkType 2. Beside ArkType 3 it loads a valid environment, and throws a TypeError in place of its report for an invalid one.

import arkenv from "@arkenv/core"

const const env: ...env = arkenv({
	HOST: "string.host",
	PORT: "number.port",
	NODE_ENV: "'development' | 'production' | 'test' = 'development'"
})

// process.env is validated and parsed when this runs
const env: ...env.HOST // string
const env: ...env.PORT // number
const env: ...env.NODE_ENV // "development" | "production" | "test"

DRZL

DRZL generates code from your Drizzle ORM schemas: ArkType validators, typed services and routers that reuse them.

// drzl.config.ts
import { defineConfig } from "@drzl/cli/config"

export default defineConfig({
	schema: "src/db/schemas/index.ts",
	outDir: "src/api",
	generators: [
		// 1) ArkType validators
		{ kind: "arktype", path: "src/validators/arktype", schemaSuffix: "Schema" },

		// 2) Routers (oRPC adapter), reusing ArkType schemas
		{
			kind: "orpc",
			template: "@drzl/template-orpc-service",
			includeRelations: true,
			outputHeader: { enabled: true },
			validation: {
				useShared: true,
				library: "arktype",
				importPath: "src/validators/arktype",
				schemaSuffix: "Schema"
			}
		},
		// 3) Typed services (Drizzle-aware or stub)
		{
			kind: "service",
			path: "src/services",
			dataAccess: "drizzle", // or 'stub'
			dbImportPath: "src/db/connection",
			schemaImportPath: "src/db/schemas"
		}
	]
})

For more details, see the Getting Started guide.

shorn

shorn turns an ArkType type into compact binary serialization. Field names and type tags stay out of the payload because the type already provides them, so there is no schema language to learn and nothing to generate.

ArkType 2.1.28 and newer implements both Standard Schema and Standard JSON Schema, so a type can be passed straight to encode. Validation runs on encode and again on decode.

import { type } from "arktype"
import { decode, encode } from "@chichurita/shorn"

const 
const Person: Type<{
    name: string;
    age: number;
    sex: "M" | "F" | "X";
}>
Person
= type({
name: "string", age: "number.integer >= 0", sex: "'M' | 'F' | 'X'" }) const const bytes: ...bytes = encode(
const Person: Type<{
    name: string;
    age: number;
    sex: "M" | "F" | "X";
}>
Person
, { name: "Grace", age: 45, sex: "F" })
const bytes: ...bytes.length // 8, where the same record is 35 bytes of minified JSON decode(
const Person: Type<{
    name: string;
    age: number;
    sex: "M" | "F" | "X";
}>
Person
, const bytes: ...bytes) // typed and validated

ArkType objects are open by default, so shorn rejects undeclared properties during encoding rather than dropping data. Use "+": "delete" to strip expected extras. See the ArkType guide for the details.