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 generate

Generate .env.example and TypeScript type declarations from your schema.

  1. Docs
  2. CLI

ctroenv generate

Generate a .env.example file from your schema.

Usage

ctroenv generate [options]

Options

OptionTypeDefaultDescription
--outputstring.env.exampleOutput file path
--no-commentsbooleanfalseOmit comments from output

Output Format

The generated file includes:

  • Comments describing each variable (from .describe() in your schema)
  • Type and required/optional annotations
  • Default values when applicable
  • Secret variables are left empty (value not written)
# CtroEnv — Environment Variables
# Generated from schema. Edit the schema, not this file.

# Primary database connection string
# Required: yes
# Type: url
DATABASE_URL=

# Server port
# Required: no
# Type: port
# Default: 3000
PORT=3000

# JWT signing secret
# Required: yes
# Type: string
# (secret — do not commit this value)
# JWT_SECRET=

# Enable debug logging
# Required: no
# Type: boolean
# Default: false
DEBUG=false

Examples

Basic generation

ctroenv generate

Custom output path

ctroenv generate --output .env.sample

Minimal output (no comments)

ctroenv generate --no-comments
DATABASE_URL=
PORT=3000
# JWT_SECRET=
DEBUG=false

How is this guide?

Edit on GitHub

Last updated on Jun 24, 2026

Previousctroenv validateNextctroenv check

On this page

UsageOptionsOutput FormatExamplesBasic generationCustom output pathMinimal output (no comments)