Typenv

Type-safe environment variables with built-in logic and validation

Move beyond simple key-value pairs. Typenv’s .envx format lets you write validated, typed, and conditionally dynamic environment files that work seamlessly with your tools.

Powerful .envx format

Replace your simple .env files with a powerful format supporting validation, types, and conditions.

Type Safety

Prevent runtime errors by defining explicit types for each environment variable.

Conditional Logic

Set values dynamically based on other variables right inside your environment files.

Editor Integration

Enjoy autocompletion, hover docs, and validation in your favorite editor.

.envx preview

This preview helps you understand the .envx syntax and structure.
1
DEV_MODE=
${NODE_ENV} == "development" ? true : false
2
API_URL=
${DEV_MODE} ? "http://localhost:3000#hash" : "https://api.example.com"
3
API_TOKEN=
${DEV_MODE} ? "dev-token" : "prod-token"
4
FULL_API_URL=
""${API_URL}?token=${API_TOKEN}&env=${NODE_ENV}""
5
PORT=
8080
required
6
DATABASE_NAME=
'db'
7
MULTILINE_EXAMPLE=
"""
I am .ENVX the best .env alternative, now you understand me!
"""
8
GREETING=
"Hello \"user\"!"
9
EMAIL=
"example@gmail.com"
10
WEBSITE_URL=
"https://www.typenv.trymagic.xyz"
required
11
BASE=
${NODE_ENV} == "development" ? "${FULL_API_URL}" : "https://api.example.com"
12
AUTH_URL=
""${BASE}/auth""
13
NODE_ENV=
development
defaultrequired
14
ANY_ARG2=
"any value"
required
14
# Variable schemas are defined at the bottom of your .envx file.
15
# They help with validation, documentation, and editor integration.
17
[DEV_MODE]
type="boolean"
description="""Conditional flag based on environment: If NODE_ENV equals 'development', DEV_MODE is true; otherwise false. Used to toggle development-specific features or debugging."""
18
[PORT]
type="number"
required=true
description="""Raw numeric value for the server port. Indicates which port the application should listen on."""
19
[EMAIL]
type="email"
description="""Raw string representing an email address. Validates format as a proper email type."""
20
[WEBSITE_URL]
type="url"
required=true
description="""Raw string representing a URL. Validates that this is a proper web address."""
21
[NODE_ENV]
type="enum"
required=true
default="development"
description="""Enum type specifying application environment. Allowed values are 'production', 'development', or 'test'. Controls environment-specific logic and configuration."""
values=["production", "development", "test"]
22
[ANY_ARG2]
type="string"
required=true
default="any value"
description="""Raw string value with a default. Generic example showing a required string parameter."""

Select a variable to view its schema.

Getting Started

Start using Typenv in just a few steps. Define your .envx file, add types and conditions, and enjoy type-safe environment variables.

  1. Create your .envx file.
  2. Define variables with types and optional conditions.
  3. Use Typenv CLI or library to validate and load your environment.
View Full Documentation

Typenv

© 2025 Typenv - Crafted with care for safer configs.

❤️ Made with love - Typenv & Trymagic