intermediate15 minutesevnx v0.2.1+

Convert reference

Deep reference for evnx convert — format-by-format output samples, processing pipeline internals, environment variables, and troubleshooting.

Convert reference

In-depth documentation for evnx convert — covering every supported output format with sample output, the internal processing pipeline, environment variable controls, and a troubleshooting guide for common issues.


Processing pipeline

Understanding the order in which evnx convert processes your variables helps predict output when combining multiple flags.

.env file
    │
    ▼
Parse → IndexMap<String, String>   (preserves insertion order)
    │
    ▼
Filter: --include pattern          (keep only matching keys)
    │
    ▼
Filter: --exclude pattern          (drop matching keys)
    │
    ▼
Transform: --prefix                (prepend string to every key)
    │
    ▼
Transform: --transform             (apply key casing)
    │
    ▼
Encode: --base64                   (base64-encode every value)
    │
    ▼
Format-specific serializer         (produces final string)
    │
    ▼
stdout  or  --output file

Key points:

  • Filtering happens before any key mutation, so --include "APP_*" matches the original keys in your .env, not the post-prefix or post-transform keys.
  • --prefix is applied before --transform, so a key named PORT with --prefix "app_" and --transform camelCase becomes appPort, not app_PORT.
  • The kubernetes format always base64-encodes values internally, independent of the --base64 flag. All other formats do not encode unless --base64 is passed.

Format reference

json

Generic JSON object. All values are strings.

Bash
evnx convert --to json
JSON
{
  "DATABASE_URL": "postgres://user:pass@localhost:5432/mydb",
  "APP_PORT": "3000"
}

Use when: Feeding config into Node.js apps, REST APIs, or any tooling that accepts a flat JSON key-value map.


yaml (alias: yml)

Generic YAML mapping. Values that look like numbers or booleans are quoted to prevent type coercion.

Bash
evnx convert --to yaml
YAML
DATABASE_URL: postgres://user:pass@localhost:5432/mydb
APP_PORT: "3000"
APP_DEBUG: "false"

Use when: Generating config files for Python, Go, or Ruby applications; or feeding into Helm chart value overrides.


shell (aliases: bash, export)

Outputs a shell script of export statements, compatible with bash and zsh. Values are double-quoted.

Bash
evnx convert --to shell
Bash
export DATABASE_URL="postgres://user:pass@localhost:5432/mydb"
export APP_PORT="3000"
export APP_DEBUG="false"

Use when: Sourcing into a shell session (source <(evnx convert --to shell)) or generating .envrc files for direnv.


aws-secrets (aliases: aws, aws-secrets-manager)

Outputs the JSON payload expected by the AWS Secrets Manager --secret-string parameter.

Bash
evnx convert --to aws-secrets --include "AWS_*"
JSON
{
  "AWS_ACCESS_KEY_ID": "AKIAIOSFODNN7EXAMPLE",
  "AWS_SECRET_ACCESS_KEY": "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY",
  "AWS_REGION": "us-east-1"
}

Pipe directly to AWS CLI:

Bash
evnx convert --to aws-secrets | \
  aws secretsmanager create-secret \
    --name prod/myapp \
    --secret-string file:///dev/stdin

gcp-secrets (aliases: gcp, gcp-secret-manager)

Outputs gcloud CLI commands to create each variable as a separate GCP Secret Manager secret.

Bash
evnx convert --to gcp-secrets --include "DATABASE_URL"
Bash
echo -n "postgres://user:pass@localhost:5432/mydb" | \
  gcloud secrets create DATABASE_URL --data-file=-

Use when: Migrating to GCP Secret Manager or scripting secret provisioning for a GCP project.


azure-keyvault (aliases: azure, azure-key-vault)

Outputs az CLI commands to set each variable as an Azure Key Vault secret.

Bash
evnx convert --to azure-keyvault --include "DATABASE_URL"
Bash
az keyvault secret set \
  --vault-name YOUR_VAULT_NAME \
  --name DATABASE-URL \
  --value "postgres://user:pass@localhost:5432/mydb"

Azure Key Vault secret names must use hyphens, not underscores. evnx converts underscores to hyphens automatically in this format.


github-actions (aliases: github, gh-actions)

Outputs gh secret set commands for the GitHub CLI, ready to paste or pipe to bash.

Bash
evnx convert --to github-actions --exclude "TEST_*"
Bash
gh secret set DATABASE_URL --body "postgres://user:pass@localhost:5432/mydb"
gh secret set APP_PORT --body "3000"

Use when: Provisioning GitHub Actions secrets from an existing .env without manually entering them in the web UI.


docker-compose (alias: compose)

Outputs the environment: block for a Docker Compose service definition.

Bash
evnx convert --to docker-compose
YAML
environment:
  DATABASE_URL: postgres://user:pass@localhost:5432/mydb
  REDIS_URL: redis://localhost:6379
  APP_PORT: "3000"
  APP_DEBUG: "false"

Paste this block under the services.<name> key in your docker-compose.yml.


kubernetes (aliases: k8s, kubectl)

Outputs a complete Kubernetes Secret manifest. Values are base64-encoded automatically by the format — do not pass --base64 alongside this format.

Bash
evnx convert --to kubernetes \
  --include "DATABASE_URL" \
  --output k8s-secret.yaml
YAML
apiVersion: v1
kind: Secret
metadata:
  name: app-secrets
type: Opaque
data:
  DATABASE_URL: cG9zdGdyZXM6Ly91c2VyOnBhc3NAbG9jYWxob3N0OjU0MzIvbXlkYg==
Bash
kubectl apply -f k8s-secret.yaml

The kubernetes format always base64-encodes values internally. Adding --base64 will double-encode them, causing your pods to receive garbled values.

Referencing the secret in a pod spec:

YAML
env:
  - name: DATABASE_URL
    valueFrom:
      secretKeyRef:
        name: app-secrets
        key: DATABASE_URL

terraform (aliases: tf, tfvars)

Outputs a .tfvars file. Keys are lowercased by default to follow Terraform convention.

Bash
evnx convert --to terraform \
  --exclude "TEST_*" \
  --output prod.tfvars
hcl
database_url = "postgres://user:pass@localhost:5432/mydb"
redis_url    = "redis://localhost:6379"
app_port     = "3000"
app_log_level = "info"

Corresponding variable declarations (add to variables.tf):

hcl
variable "database_url" { type = string }
variable "redis_url"    { type = string }
variable "app_port"     { type = string }
variable "app_log_level" { type = string }

doppler

Outputs the JSON payload for Doppler's bulk import API.

Bash
evnx convert --to doppler
JSON
{
  "DATABASE_URL": "postgres://user:pass@localhost:5432/mydb",
  "APP_PORT": "3000"
}

heroku

Outputs a single heroku config:set command with all variables as key=value pairs.

Bash
evnx convert --to heroku --exclude "TEST_*"
Bash
heroku config:set \
  DATABASE_URL="postgres://user:pass@localhost:5432/mydb" \
  APP_PORT="3000" \
  APP_LOG_LEVEL="info"

Pipe directly to run immediately:

Bash
evnx convert --to heroku --exclude "TEST_*" | bash

vercel

Outputs the JSON format accepted by Vercel's environment variable import.

Bash
evnx convert --to vercel
JSON
[
  { "key": "DATABASE_URL", "value": "postgres://user:pass@localhost:5432/mydb", "type": "encrypted", "target": ["production"] },
  { "key": "APP_PORT", "value": "3000", "type": "plain", "target": ["production"] }
]

railway

Outputs the JSON format for Railway's variable import.

Bash
evnx convert --to railway
JSON
{
  "DATABASE_URL": "postgres://user:pass@localhost:5432/mydb",
  "APP_PORT": "3000"
}

Environment variables

These shell environment variables affect evnx convert behaviour:

VariableValuesEffect
NO_COLOR1, trueDisables all ANSI colour in terminal output
CI1, trueInteractive TUI is disabled; --to becomes required

Troubleshooting

Unknown format error

✗ Unknown format: k8s-secret

Supported formats:
  Generic:      json, yaml, shell
  ...
  Aliases:      k8s → kubernetes, tf → terraform

Cause: The format name was misspelled or an unsupported alias was used.

Fix: Use the canonical name (kubernetes) or a supported alias (k8s). Run evnx convert --help for the full list.


Input file not found

Error: Failed to validate input file: '.env.production'
Caused by: Input file not found: '.env.production'

Fix: Pass an explicit --env path, or run from the directory that contains your .env file:

Bash
evnx convert --to json --env /absolute/path/to/.env.production

Double base64-encoding in Kubernetes output

Symptom: Pod environment variables contain garbled strings like cG9zdGdyZXM6Ly91c2Vy... instead of your actual values.

Cause: The kubernetes format already base64-encodes values. Adding --base64 encodes them a second time.

Bash
# ❌ Double-encodes — values will be garbled in the pod
evnx convert --to kubernetes --base64

# ✅ Correct — kubernetes handles encoding internally
evnx convert --to kubernetes

Glob pattern not matching expected variables

Symptom: --include "AWS*" returns no results, but AWS_KEY is in your .env.

Cause: Glob patterns require explicit wildcard placement. AWS* matches AWS_KEY only if the * covers the _KEY portion — which it does — but a common mistake is omitting the wildcard entirely.

Fix: Always include * after the prefix, with the underscore:

Bash
# ❌ Matches only the literal string "AWS"
evnx convert --include "AWS" --to json

# ✅ Matches AWS_KEY, AWS_REGION, AWS_SECRET_ACCESS_KEY
evnx convert --include "AWS_*" --to json

Prefix and transform produce unexpected key names

Symptom: With --prefix "app_" and --transform camelCase, the key PORT becomes appPort rather than app_PORT.

Explanation: This is the correct and intended behaviour. The pipeline is: original key → prefix applied → transform applied.

PORT
→ app_PORT     (after --prefix "app_")
→ appPort      (after --transform camelCase)

If you want app_PORT in the output, omit --transform or use uppercase:

Bash
evnx convert --prefix "app_" --transform uppercase
# PORT → app_PORT → APP_PORT

camelCase produces all-lowercase first word

Symptom: MY_API_KEY with --transform camelCase becomes myApiKey (first word fully lowercased).

Explanation: This is by design. The camelCase transform lowercases the first word segment entirely, regardless of how many characters it has.

Workaround: If you need a specific capitalisation, pre-process the key with --transform snake_case first, then pipe through a second conversion — or use a post-processing step with jq:

Bash
evnx convert --to json --transform camelCase | \
  jq 'with_entries(.key |= gsub("^(?<a>[A-Z])"; (.a | ascii_downcase)))'

Azure Key Vault rejects secret names with underscores

Cause: Azure Key Vault does not allow underscores in secret names.

Explanation: The azure-keyvault format automatically converts underscores to hyphens. DATABASE_URL becomes DATABASE-URL in the generated az commands. This is expected and matches Azure requirements.


See also