Validators
Choose between @arkenv/core and @arkenv/standard, then wire ArkType, Zod, or Valibot.
ArkType, Zod, and Valibot can all describe an environment variable.
ArkEnv ships two engines that share arkenv(), fail-fast errors, and
the framework plugins. You pick the one that matches the schemas you
already write.
Shared options (env, coerce, and the
rest) apply to both. toJsonSchema is on @arkenv/standard only.
ArkType already exposes JSON Schema. The engines differ in schema style
and peer dependencies.
@arkenv/core | @arkenv/standard | |
|---|---|---|
| Schema style | ArkType DSL strings + type() | Per-key Standard Schema validators |
| Typical libraries | ArkType | Zod, Valibot |
Runtime dependencies | None | None |
Peer arktype | Required | None |
Env keywords (string.host, number.port) | Yes | Use the validator's own APIs |
| Coercion | Built-in | Built-in when fields expose Standard JSON Schema v1, via /valibot or /zod-mini, or via toJsonSchema |
| Framework plugins | @arkenv/nextjs, … | Same packages via /standard subpaths |
Pick the engine that matches the schema library you write, then follow the cookbook below.
Side by side
The same keys, three declaration styles. Zod 4.2+ does not need
z.coerce, and Valibot does not need v.transform(Number); ArkEnv
coerces first.
import from "@arkenv/core";
export const = ({
DATABASE_URL: "string",
PORT: "number.port = 3000",
: "'development' | 'production' | 'test' = 'development'",
});Install either stack the same way you would any env schema: one validation package, then framework plugins if you need them.
ArkType engine:
npm install @arkenv/core arktypeStandard Schema engine (Zod):
npm install @arkenv/standard zodStandard Schema engine (Valibot):
npm install @arkenv/standard valibot @valibot/to-json-schemaWhen each fits
| Situation | Engine |
|---|---|
| You want ArkType's DSL and ArkEnv keywords | @arkenv/core |
| The app already uses Zod or Valibot for other schemas | @arkenv/standard |
| You must stay ArkType-free | @arkenv/standard |
| You are scaffolding a new TypeScript app and like ArkType | @arkenv/core |
ArkType itself implements Standard Schema. If you already depend on
ArkType, stay on @arkenv/core rather than wrapping ArkType types
through @arkenv/standard.
Packaging
Engines are separate packages so peer dependencies stay honest.
Framework plugins stay single packages with /standard subpaths
(@arkenv/nextjs/standard, @arkenv/vite-plugin/standard, and so on)
instead of a second npm package per host.
JSON Schema and coercion
Standard Schema and Standard JSON Schema are orthogonal specs: one is about validation, the other about converting a type to JSON Schema. A value can implement one, both, or neither.
ArkEnv's pre-coercion step for @arkenv/standard prefers Standard
JSON Schema v1 on the value (~standard.jsonSchema.input /
.output). When a library keeps conversion outside the schema, use a
first-class subpath or the optional
toJsonSchema
escape hatch.
| Library | How ArkEnv gets JSON Schema |
|---|---|
| Zod (v4.2+) | On the value (Standard JSON Schema v1) |
| VineJS (v4.3+) | On the value (Standard JSON Schema v1) |
Valibot (v1.2+ with @valibot/to-json-schema) | @arkenv/standard/valibot (see Valibot) |
| Zod Mini | @arkenv/standard/zod-mini (mixing) |
| Other Standard JSON Schema v1 validators | On the value |
See Coercion and parsing.
A one-file Env.assert(process.env) works for a hello-world Node
script. ArkEnv adds env-specific errors, automatic coercion, a CLI, and
framework plugins that keep server secrets out of the client graph. See
Why ArkEnv? for DIY, Varlock, T3 Env, znv, Envalid, and
related tools.
Cookbooks
ArkType
@arkenv/core, ArkType DSL, and built-in coercion.
Zod
@arkenv/standard with Zod 4.2+, Zod Mini, or Zod v3.
Valibot
@arkenv/standard/valibot with coercion wired through JSON Schema.
@arkenv/core
ArkType engine package reference.
@arkenv/standard
Standard Schema engine package reference.
Defining your schema
Declare field types for either engine.