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.
.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=truedescription="""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=truedescription="""Raw string representing a URL. Validates that this is a proper web address."""
21
[NODE_ENV]type="enum"required=truedefault="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=truedefault="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.
- Create your
.envx
file. - Define variables with types and optional conditions.
- Use Typenv CLI or library to validate and load your environment.