Kubernetes secret decoder

Runs in your browser

Paste kubectl get secret -o yaml and see every value decoded, including TLS certificates, registry logins and tokens. Create Secret manifests.

Try:

Paste the output of kubectl get secret NAME -o yaml (or -o json). Every value is decoded at once, certificates, registry logins and tokens included.

Good to know

A Secret is not encrypted

The values under data are only Base64. Anyone who may get the secret can read it, and by default etcd stores it unencrypted. Protect secrets with RBAC, encryption at rest (EncryptionConfiguration or your cloud’s KMS) and keep them out of git, for example with Sealed Secrets, SOPS or the External Secrets Operator.

In your terminal

Read and write secrets with kubectl

One value
kubectl get secret db-credentials -o jsonpath='{.data.password}' | base64 -d
All values
kubectl get secret db-credentials -o json | jq -r '.data | map_values(@base64d)'

# without jq
kubectl get secret db-credentials -o go-template='{{range $k, $v := .data}}{{$k}}: {{$v | base64decode}}{{"\n"}}{{end}}'
Create
kubectl create secret generic db-credentials --from-literal=password='s3cr3t'
kubectl create secret tls web-tls --cert=fullchain.pem --key=privkey.pem
kubectl create secret docker-registry regcred --docker-server=ghcr.io \
  --docker-username=octocat --docker-password="$TOKEN"
Encode by hand
printf '%s' 's3cr3t' | base64      # right
echo 's3cr3t' | base64           # wrong: encodes a newline too
Common mistakes

Why the app can’t log in

Newline in the value

echo value | base64 stores value\n. The tool flags every value that ends with a line break.

Encoded twice

Values under stringData are plain text; under data they must be Base64. Base64 under stringData ends up encoded twice.

Wrong key names

A TLS secret needs tls.crt and tls.key; an image pull secret needs .dockerconfigjson.

Pod still has the old value

Environment variables from a secret are read when the container starts. Restart the deployment; mounted files update after about a minute.

FAQ

Questions about the kubernetes secret decoder

How do I decode a Kubernetes secret?

Each value under data is Base64: kubectl get secret NAME -o jsonpath='{.data.KEY}' | base64 -d. Or paste the whole -o yaml output above to see every value at once.

Is Base64 encryption?

No. Base64 only makes binary data safe for YAML. Anyone can decode it, which is why access to secrets must be restricted.

What is the difference between data and stringData?

data holds Base64 values, stringData plain text. Kubernetes converts stringData to data when you apply it, so kubectl get always shows data.

Is it safe to paste a production secret here?

It is decoded in your browser and never sent anywhere; the page’s security policy forbids it. If you are unsure, use the kubectl commands on this page instead.

Searches the list of pages on this site. What you type stays in your browser.