Convert basics
Step-by-step examples for transforming .env files with evnx convert — JSON, Kubernetes, filtering, transforms, and CI/CD pipelines.
Prerequisites
Convert basics
This guide walks through the most common evnx convert workflows with concrete
before-and-after examples. For the full flag reference, see
evnx convert.
Before you start
Your starting .env
All examples on this page assume the following .env:
# .env
DATABASE_URL=postgres://user:pass@localhost:5432/mydb
REDIS_URL=redis://localhost:6379
AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE
AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
AWS_REGION=us-east-1
APP_DEBUG=false
APP_PORT=3000
APP_LOG_LEVEL=info
TEST_ONLY_VAR=not-for-prodInteractive mode
The fastest way to explore formats. Run evnx convert with no flags:
evnx convertA TUI menu appears:
┌─ Convert environment variables ─────────────────────┐
│ Transform .env into different formats │
└──────────────────────────────────────────────────────┘
Select output format
❯ json - Generic JSON key-value object
yaml - Generic YAML key-value format
shell - Shell export script (bash/zsh)
aws-secrets - AWS Secrets Manager (CLI commands)
...
Use ↑/↓ to navigate, Enter to confirm, Ctrl+C to cancel. Useful for one-off tasks or when you can't remember a format name.
Basic format conversion
JSON
evnx convert --to jsonOutput:
{
"DATABASE_URL": "postgres://user:pass@localhost:5432/mydb",
"REDIS_URL": "redis://localhost:6379",
"AWS_ACCESS_KEY_ID": "AKIAIOSFODNN7EXAMPLE",
"AWS_SECRET_ACCESS_KEY": "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY",
"AWS_REGION": "us-east-1",
"APP_DEBUG": "false",
"APP_PORT": "3000",
"APP_LOG_LEVEL": "info",
"TEST_ONLY_VAR": "not-for-prod"
}YAML
evnx convert --to yamlOutput:
DATABASE_URL: postgres://user:pass@localhost:5432/mydb
REDIS_URL: redis://localhost:6379
AWS_ACCESS_KEY_ID: AKIAIOSFODNN7EXAMPLE
AWS_SECRET_ACCESS_KEY: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
AWS_REGION: us-east-1
APP_DEBUG: "false"
APP_PORT: "3000"
APP_LOG_LEVEL: info
TEST_ONLY_VAR: not-for-prodShell export script
evnx convert --to shellOutput:
export DATABASE_URL="postgres://user:pass@localhost:5432/mydb"
export REDIS_URL="redis://localhost:6379"
export AWS_ACCESS_KEY_ID="AKIAIOSFODNN7EXAMPLE"
export AWS_SECRET_ACCESS_KEY="wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
export AWS_REGION="us-east-1"
export APP_DEBUG="false"
export APP_PORT="3000"
export APP_LOG_LEVEL="info"
export TEST_ONLY_VAR="not-for-prod"Writing to a file
Use --output (or -o) to write to a file instead of stdout:
evnx convert --to json --output config.json
evnx convert --to yaml -o config.yaml
evnx convert --to terraform --output prod.tfvarsFiltering variables
Include only variables matching a pattern
evnx convert --to json --include "AWS_*"Output:
{
"AWS_ACCESS_KEY_ID": "AKIAIOSFODNN7EXAMPLE",
"AWS_SECRET_ACCESS_KEY": "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY",
"AWS_REGION": "us-east-1"
}Exclude variables matching a pattern
evnx convert --to json --exclude "TEST_*"All variables are included except TEST_ONLY_VAR.
Combine include and exclude
Exclude is applied after include, so you can narrow down a broad match:
evnx convert --to json \
--include "APP_*" \
--exclude "*_DEBUG"Output — APP_DEBUG is excluded because it matches *_DEBUG:
{
"APP_PORT": "3000",
"APP_LOG_LEVEL": "info"
}Transforming key names
Uppercase
evnx convert --to json --include "APP_*" --transform uppercaseInput keys are already uppercase, so output is unchanged.
Lowercase
evnx convert --to json --include "APP_*" --transform lowercaseOutput:
{
"app_debug": "false",
"app_port": "3000",
"app_log_level": "info"
}camelCase
Useful for JavaScript/TypeScript configuration:
evnx convert --to json --include "APP_*" --transform camelCaseOutput:
{
"appDebug": "false",
"appPort": "3000",
"appLogLevel": "info"
}snake_case
evnx convert --to json --include "APP_*" --transform snake_caseOutput (already snake_case, so keys are lowercased):
{
"app_debug": "false",
"app_port": "3000",
"app_log_level": "info"
}Adding a prefix
--prefix prepends a string to every key, applied before --transform:
evnx convert --to json \
--include "DATABASE_URL" \
--prefix "MYAPP_"Output:
{
"MYAPP_DATABASE_URL": "postgres://user:pass@localhost:5432/mydb"
}Combining prefix and transform
evnx convert --to json \
--include "APP_*" \
--prefix "prod_" \
--transform camelCaseKey pipeline: APP_PORT → prod_APP_PORT → prodAppPort
Output:
{
"prodAppDebug": "false",
"prodAppPort": "3000",
"prodAppLogLevel": "info"
}Kubernetes secret
The kubernetes format always base64-encodes values per the Kubernetes spec.
Do not add --base64 — it would double-encode.
evnx convert --to kubernetes \
--include "DATABASE_URL" \
--output k8s-secret.yamlOutput written to k8s-secret.yaml:
apiVersion: v1
kind: Secret
metadata:
name: app-secrets
type: Opaque
data:
DATABASE_URL: cG9zdGdyZXM6Ly91c2VyOnBhc3NAbG9jYWxob3N0OjU0MzIvbXlkYg==Apply directly:
kubectl apply -f k8s-secret.yamlBase64-encoding values
For formats that don't auto-encode (like JSON or YAML), --base64 encodes every value:
evnx convert --to json --include "AWS_*" --base64Output:
{
"AWS_ACCESS_KEY_ID": "QUtJQUlPU0ZPRE5ON0VYQU1QTEU=",
"AWS_SECRET_ACCESS_KEY": "d0phbHJYVXRuRkVNSS9LN01ERU5HL2JQeFJmaUNZRVhBTVBMRUtFWQ==",
"AWS_REGION": "dXMtZWFzdC0x"
}Piping output to cloud CLIs
AWS Secrets Manager
evnx convert --to aws-secrets | \
aws secretsmanager create-secret \
--name prod/myapp \
--secret-string file:///dev/stdinHeroku
evnx convert --to heroku | bash
# Runs: heroku config:set KEY=value KEY2=value2 ...CI/CD: GitHub Actions
Generate a shell script to set GitHub secrets via the gh CLI:
evnx convert --to github-actions \
--exclude "TEST_*" \
--output set-secrets.sh
bash set-secrets.shOr inline in a workflow step:
# .github/workflows/deploy.yml
- name: Set secrets
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
run: |
evnx convert --to github-actions --exclude "TEST_*" | bashTerraform
evnx convert --to terraform \
--exclude "TEST_*" \
--transform lowercase \
--output prod.tfvarsOutput (prod.tfvars):
database_url = "postgres://user:pass@localhost:5432/mydb"
redis_url = "redis://localhost:6379"
app_port = "3000"
app_log_level = "info"Verbose output
--verbose (or -v) prints progress to stderr, leaving stdout clean for piping:
evnx convert --to json --verbose 2>convert.logconvert.log will contain:
🔄 Running convert in verbose mode: .env
📦 Loaded 9 variables from .env
⚙️ Converting to json format...
✓ Output written to stdout