ArkEnv

Validator mode

Configure how ArkEnv validates and coerces your environment variables.

ArkEnv supports two validator modes that control how environment variables are parsed and validated.
You select the mode via the validator option in the arkenv configuration.

Cheatsheet - when to use which?

Featurearktype (default)standard
ArkType DSL✅ Native⚠️ Via type(...)
Standard Schema (Zod, Valibot, Typia)✅ Yes✅ Yes
Automatic coercion✅ Yes❌ Validator-defined
Requires arktype✅ Yes❌ No
Best forNew projects, maximal DXMigrations, ArkType-free setups

In a new project, prefer the default arktype mode. standard exists for migrations and ArkType-free setups.


validator: "arktype" (default)

ArkEnv runs validation through ArkType and expects it to be installed.

What you get

  • Native support for ArkType's string-based DSL ("string.url", "number > 0", etc.)
  • Built-in, intuitive coercion from strings
  • Full Standard Schema support (Zod, Valibot, etc.)
import  from 'arkenv';
import {  } from 'arkenv/arktype';
import {  } from 'zod';

const  = ({
  : "number.port",
  : ("'development' | 'production'"),
  : .().(),
});

Requirements

You must install arktype alongside arkenv.


validator: "standard"

In Standard mode, ArkEnv works directly with any validator that implements the Standard Schema interface, without ArkType.

When this makes sense

  • You already use Zod or Valibot everywhere
  • You want a zero-ArkType runtime
  • You care more about minimal dependencies than DSL ergonomics

Tradeoffs

  • No native ArkType DSL strings ("number.port", "string.host")
  • No ArkType coercion - use your validator's native coercion instead
import  from 'arkenv';
import {  } from 'zod';

const  = (
  {
    : ..().().(0).(65535),
    : .().(),
  },
  { : "standard" }
);

Requirements

A validator that implements Standard Schema (e.g. zod@^3.24.0, valibot@^1.0.0).