Env Loader

Typed environment variable loading and validation. Zero dependencies.

Example: load(schema, source)

Schema

{
  "NODE_ENV": {
    "type": "string",
    "default": "development"
  },
  "PORT": {
    "type": "number",
    "default": 3000
  },
  "DEBUG": {
    "type": "boolean",
    "default": false
  },
  "API_KEY": {
    "type": "string",
    "secret": true
  }
}

Source (raw env)

{
  "NODE_ENV": "production",
  "PORT": "8080",
  "DEBUG": "true",
  "API_KEY": "sk-live-abc123secret"
}

Result (typed, parsed)

{
  "NODE_ENV": "production",
  "PORT": 8080,
  "DEBUG": true,
  "API_KEY": "sk-live-abc123secret"
}

toSafeLog() — secrets masked

{
  "NODE_ENV": "production",
  "PORT": 8080,
  "DEBUG": true,
  "API_KEY": "***"
}