CtroEnv
ctroenvType-Safe Environment Variables
Getting StartedQuick StartCore Concepts
defineEnv()string()number()boolean()pick()Chainable MethodsRefinementsError HandlingSchema Composition
CLI Overviewctroenv validatectroenv generatectroenv checkctroenv docsctroenv initCLI Configuration
Node AdapterVite AdapterNext.js Adapter
Migration from t3-envMigration from envalidMigration from dotenv

ctroenv validate

Validate current environment variables against your schema from the CLI.

  1. Docs
  2. CLI

ctroenv validate

Validate environment variables against your schema.

Usage

ctroenv validate [options]

Options

OptionTypeDefaultDescription
--sourcestringprocess.envPath to a .env file
--watchbooleanfalseWatch for file changes
--jsonbooleanfalseOutput as JSON

Examples

Basic validation

ctroenv validate

Validates against process.env using the schema from ctroenv.config.ts.

With .env file

ctroenv validate --source .env.local

Watch mode

ctroenv validate --watch

Re-validates when your schema or env files change. Useful during development.

JSON output

ctroenv validate --json

Outputs validation results as JSON for programmatic consumption:

{
  "valid": false,
  "source": ".env",
  "total": 5,
  "errors": 2,
  "variables": [
    {
      "key": "DATABASE_URL",
      "type": "string",
      "value": "postgresql://...",
      "required": true,
      "description": "Primary database connection",
      "isSecret": false,
      "hasDefault": false
    }
  ]
}

Exit Codes

CodeMeaning
0All variables valid
1Validation errors found
2Configuration error

How is this guide?

Edit on GitHub

Last updated on Jun 24, 2026

PreviousCLI OverviewNextctroenv generate

On this page

UsageOptionsExamplesBasic validationWith .env fileWatch modeJSON outputExit Codes