OpsPane

Turn a .env file into the exact ConfigMap or Secret kubectl creates from it, with the same quotes, keys and errors, or a manifest back into .env.

Convert

Read in this tab — nothing is uploaded or put in the URL.

Create a
Namespace and labels (optional)

5 keys · 60 bytes of values.

configmap.yaml
apiVersion: v1
data:
  APP_ENV: production
  CACHE_TTL: '300 # seconds'
  DATABASE_URL: '"postgres://app@db:5432/shop"'
  LOG_LEVEL: info
  PORT: "8080"
kind: ConfigMap
metadata:
  name: app-config

What kubectl stores

Every value exactly as written after the first = — quotes and # included.

  1. Line 2key APP_ENVvalue production
  2. Line 3key LOG_LEVELvalue info
  3. Line 4key PORTvalue 8080
  4. Line 5key DATABASE_URLvalue "postgres://app@db:5432/shop"
  5. Line 6key CACHE_TTLvalue 300 # seconds

Where Docker Compose and dotenv read it differently

2 lines of this file would give a different value under docker compose (env_file) or the npm dotenv package.

  • Line 5DATABASE_URL="postgres://app@db:5432/shop"

    kubectl
    DATABASE_URL="postgres://app@db:5432/shop"
    Docker Compose
    DATABASE_URL=postgres://app@db:5432/shop
    dotenv
    DATABASE_URL=postgres://app@db:5432/shop

    quotes

  • Line 6CACHE_TTL=300 # seconds

    kubectl
    CACHE_TTL=300 # seconds
    Docker Compose
    CACHE_TTL=300
    dotenv
    CACHE_TTL=300

    inline comment

Use it

The command that writes the same manifest, and how a Deployment's container reads the keys.

kubectl command
Deployment: every key (envFrom)
Deployment: one key at a time (env.valueFrom)
Updated Runs locally in your browser

Quick answer

  • kubectl's --from-env-file stores everything after the first = as written: GREETING="hello" becomes "hello", quotes included.
  • No export prefix: kubectl reads export AWS_REGION as the key and rejects it as not a valid key name.
  • A repeated key is an error, where Docker Compose and dotenv let the last line win.
  • A line with a key and no = takes its value from kubectl's shell, empty if unset. All values together may hold at most 1,048,576 bytes (1 MiB).

How to convert a .env file to a ConfigMap or Secret

  1. Paste your .env file, or pick an example. Choose ConfigMap or Secret, a name, and optionally a namespace and labels.
  2. If a line has a key and no =, kubectl takes its value from your shell. Type it under Values from your shell, paste the output of env, or mark the key unset. These values stay in the tab's memory: never in the URL, browser storage or analytics, and Reset clears them.
  3. Read the manifest next to the file: it is the YAML that kubectl create with --from-env-file and --dry-run=client -o yaml prints, with the same key order and quoting. If kubectl would refuse the file, you see its exact error and the line.
  4. Check What kubectl stores and the Docker Compose / dotenv differences, then copy or download the manifest — or copy the command and run it yourself.
  5. To go the other way, switch to manifest → .env and paste a ConfigMap or Secret.

Parsing rules: kubectl vs Docker Compose vs dotenv

The same file reads three different ways. Each cell below is computed by this page's engines: kubectl's env-file reader, a port of Docker Compose's parser (compose-go) and the npm dotenv parser.

Linekubectl storesDocker Composedotenv
Quotes around a valueGREETING="hello world""hello world"hello worldhello world
Single quotesTOKEN='abc 123''abc 123'abc 123abc 123
Escape sequencesMESSAGE="line 1\nline 2""line 1\nline 2"line 1↵line 2line 1↵line 2
Inline comment after a spaceTIMEOUT=30 # seconds30 # seconds3030
# inside a valueURL=https://example.test/#tophttps://example.test/#tophttps://example.test/#tophttps://example.test/
export prefixexport REGION=eu-west-1error: not a valid key nameeu-west-1eu-west-1
Spaces around =NAME = weberror: not a valid key namewebweb
Variable referenceDATA_DIR=$HOME/data$HOME/data$HOME/data (variables substituted)$HOME/data
KEY: valuePORT: 8080error: not a valid key name80808080
Key without =GIT_SHAvalue from the shell, empty if unsetvalue from the shell, left out if unsetline ignored

Also: kubectl rejects a repeated key, while Compose and dotenv keep the last one. All three skip blank lines and lines starting with #, and none of them minds a UTF-8 BOM at the start of the file.

Gotchas this tool checks for

Quotes and comments become part of the value

A file written for Docker Compose usually quotes values with spaces and adds comments after them. kubectl keeps both: CACHE_TTL=300 # seconds stores 300 # seconds, and your app reads that string. The differences list under the tool flags every such line.

One line per variable

kubectl reads the file line by line, so a quoted value that spans lines — a certificate, a JSON blob — breaks: the first line keeps an opening quote and the next line fails as a key. Put multi-line values in their own file and use --from-file instead.

Keys without a value come from the shell — even when unset

A line such as GIT_SHA makes kubectl call os.Getenv("GIT_SHA") in its own process. If the variable is not exported in that shell, kubectl does not skip the key: it stores an empty value, the same as for GIT_SHA=. Docker Compose leaves an unset key out instead. The value is used exactly as the shell holds it — line breaks, quotes, spaces and # included — and it is not limited to one line, since it never passes through the file reader.

When you paste env output, a value that spans several lines continues until a line that starts with NAME=; a continuation line that itself looks like NAME=… cannot be told apart, so check multi-line values. The command under Use it adds env -u KEY for keys you mark unset and never repeats a value you typed, so it stays out of your shell history.

A line of 64 KiB stops the file silently

kubectl's line reader gives up on a line of 65,536 bytes or more and never reports it: that key and everything after it are missing from the manifest, with no error. The tool warns when this happens.

Control characters

A ConfigMap value with a DEL or C1 control character makes kubectl fail with the error “yaml: control characters are not allowed”, and a NEL character is folded into a space. A Secret keeps both, because base64 carries the bytes.

A Secret is base64, not encryption

Anyone who can read the manifest can decode every value with one command. Kubernetes stores Secrets unencrypted in etcd unless encryption at rest is configured, and anyone allowed to create a Pod in the namespace can mount them.

Decode a Secret and see why

The 1 MiB limit

The API server rejects a ConfigMap or Secret whose values add up to more than 1,048,576 bytes (1 MiB). The tool shows the total and warns above the limit; large files belong in a volume, not in an object.

Verification

FAQ

Does kubectl --from-env-file remove quotes from values?

No. kubectl stores everything after the first "=" exactly as written, so GREETING="hello" becomes the 7-character value "hello", quotes included. Docker Compose and the dotenv package strip them, which is why the same file can behave differently in a container started by Compose and in a Pod.

Why does kubectl say "export AWS_REGION" is not a valid key name?

kubectl does not understand the shell export prefix, so the key becomes "export AWS_REGION" — with a space — and fails the environment-variable name check: error: "export AWS_REGION" is not a valid key name: a valid environment variable name must consist of alphabetic charact… Remove "export " from the file; Compose and dotenv strip it silently.

What happens when a key appears twice?

kubectl stops with an error instead of keeping the last value: error: cannot add key "PORT", another key by that name already exists in Data for ConfigMap "app-config". Docker Compose and dotenv let the later line win, so a file that works for them can fail here.

What does a line with only a key, and no "=", do?

kubectl reads that variable from the environment of the shell running it, with Go's os.Getenv. An unset variable and an empty one look the same to it, so an unset GIT_SHA still becomes a key with an empty value (GIT_SHA: ""); Docker Compose would leave the key out. Enter the value your shell holds under Values from your shell, paste the output of env, or mark the key unset, and the manifest shows exactly what kubectl would store.

Why are some values quoted in the YAML?

go-yaml quotes a string that would otherwise read back as a number, a boolean or null, so it stays a string: DEBUG: "false", LOG_LEVEL: info, PORT: "8080", name: app-config. The value is the same text in every case; ConfigMap data only holds strings.

Should a Secret use data or stringData?

kubectl create secret writes data, with each value base64-encoded (hunter2 becomes aHVudGVyMg==). stringData takes plaintext and the API server encodes it on write, which reads better in review but is not what kubectl prints. Both are stored the same way.

Is a Secret encrypted?

No — base64 is an encoding, reversible by anyone who can read the manifest. Kubernetes documents that Secrets are stored unencrypted in etcd by default; protection comes from encryption at rest and RBAC. The Secret decoder page shows the round trip.

Can I turn a ConfigMap or Secret back into a .env file?

Yes: switch to manifest → .env and paste the YAML. Secret values are decoded in the tab. Values an env file cannot hold — line breaks, binary data, keys that are not valid variable names — are left out and listed, so the file you get reads back into the same data.

Private by design

Your input is processed in this browser tab and never sent to our servers. Privacy policy