Pages

Topics

Tools

↑↓navigate↵openescclose
Encoding & Security

.env ↔ K8s / Compose

Convert .env variables into a Kubernetes Secret or ConfigMap, a Docker Compose environment block, JSON or GitHub Actions env, and decode a Secret, ConfigMap or Compose service back into a .env file.

Runs entirely in your browser — nothing you paste is uploaded.

Output format
Presets
Keys named like SECRET, KEY, TOKEN, PASSWORD, DSN or URL are treated as credentials.
359 chars
5 variables4 sensitive keys

Nothing you paste leaves this browser tab; the conversion runs in your memory.

live
Kubernetes Secret
447 chars · 11 lines
apiVersion: v1
kind: Secret
metadata:
  name: app-secrets
type: Opaque
data:
  NEXT_PUBLIC_SUPABASE_URL: aHR0cHM6Ly94eXpjb21wYW55LnN1cGFiYXNlLmNv
  NEXT_PUBLIC_SUPABASE_ANON_KEY: ZXlKaGJHY2lPaUpJVXpJMU5pSXNJblI1Y0NJNklrcFhWQ0o5LmV5SnliMnhsSWpvaVlXNXZiaUo5LmRlbW8=
  SUPABASE_SERVICE_ROLE_KEY: c2VydmljZS1yb2xlLWtleS1mcm9tLXRoZS1kYXNoYm9hcmQ=
  DATABASE_URL: cG9zdGdyZXM6Ly9wb3N0Z3Jlczpwd0BkYi5pbnRlcm5hbDo1NDMyL2FwcA==
  NODE_ENV: cHJvZHVjdGlvbg==

Secret values are Base64-encoded as UTF-8, which is what Kubernetes expects in data.

Credential keys
  • NEXT_PUBLIC_SUPABASE_URLhttps://xyzcompany.supabase.co
  • NEXT_PUBLIC_SUPABASE_ANON_KEYeyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlIjoiYW5vbiJ9.demo
  • SUPABASE_SERVICE_ROLE_KEYservice-role-key-from-the-dashboard
  • DATABASE_URLpostgres://postgres:pw@db.internal:5432/app

Kubernetes Secret and Compose cheat sheet

quick reference
KEY=VALUE
The dotenv format: one pair per line, an optional export prefix, # starts a comment, and quotes keep spaces or an inline # inside the value.
kubectl create secret generic app --from-env-file=.env
Creates a Secret whose keys are the variables of the file — the command-line version of what this tool writes.
data vs stringData
data holds Base64 of the UTF-8 bytes and is what the API returns; stringData takes plain text and Kubernetes encodes it when the object is written.
printf %s "$VALUE" | base64
Encodes one value by hand. Use printf or echo -n, because a trailing newline silently becomes part of the decoded secret.
environment:
In Compose a mapping passes YAML strings straight through, while a - KEY=VALUE list goes through Compose interpolation and handles ${VAR} references.
envFrom.secretRef
Mounts every key of a Secret as an environment variable in a container; envFrom.configMapRef does the same for a ConfigMap.

Frequently asked questions

answered below the tool
Should a Secret use data or stringData?

stringData takes plain text and is easier to read; data holds Base64 and is what the API returns. Both describe the same Secret.

Why is the decoded value one character longer?

echo adds a newline before Base64 encoding. Use printf %s or echo -n so the newline never becomes part of the secret.

Can I turn a Secret back into .env?

Yes. Paste the Secret, ConfigMap or Compose service and choose the reverse direction; the values come back as KEY=VALUE lines.

All Docker guides