YAML to Base64

Encode YAML or Kubernetes secret values to Base64 and decode them back.

0 chars
0 words
0 lines
0 chars
0 words
0 lines

YAML to Base64 for Kubernetes Secrets and CI/CD

This converter encodes YAML to Base64 and decodes it back, with a special mode for the most common DevOps task: filling the data: block of a Kubernetes Secret. You can encode a whole YAML file as one Base64 string, or keep the keys and encode each value individually.

Two ways to encode

Whole document (default) turns the complete YAML text, indentation and comments included, into a single Base64 string. That's what you want when a pipeline variable must hold an entire config file, for example a kubeconfig, a Helm values.yaml, or a GitHub Actions secret that a job writes back to disk with echo "$CONFIG" | base64 -d > config.yaml.

Only values (key: value) keeps every key and encodes just the part after the first : . Comments and empty lines are left alone, and surrounding quotes are removed. The line DB_PASSWORD: s3cr3t-P@ss becomes DB_PASSWORD: czNjcjN0LVBAc3M=, ready to paste under data: in a manifest:

apiVersion: v1
kind: Secret
metadata:
name: app-secrets
type: Opaque
data:
DB_PASSWORD: czNjcjN0LVBAc3M=

Decoding

Switch to Base64 to YAML to turn a Base64 blob back into readable YAML, for instance the output of kubectl get secret app-secrets -o yaml or an encoded CI variable. The decoder tolerates whitespace, line breaks, missing padding, and URL-safe characters.

Tips for CI/CD

GitLab CI, GitHub Actions, Bitbucket Pipelines, and Azure DevOps all mask secret variables better when they are a single line, which is why multi-line YAML is usually stored as Base64. Avoid line wrapping for these values. For JSON configs such as Docker registry credentials use JSON to Base64, and for secrets in URL parameters see URL Encode / Decode.

Frequently Asked Questions

Paste your key: value pairs, turn on 'Only values (key: value)', and copy the result under data: in your Secret manifest. Each value is Base64-encoded separately while keys stay readable, exactly like kubectl create secret generic --from-literal does.

The value was probably encoded with echo 'value' | base64, which includes the trailing newline. Use echo -n or printf, or encode it here: the Only values mode trims whitespace around each value before encoding.

Yes. Kubernetes also accepts plain text in stringData and encodes it for you. Base64 in data is still common in Helm charts, GitOps repositories, and when values contain binary content such as certificates or keystores.

No. Base64 is only an encoding and anyone with read access can decode it. Protect secrets with RBAC, encryption at rest, and tools like Sealed Secrets, SOPS, or an external secret manager.