.env · transform🔒 100% client-side — never leaves your browser

ENV to Base64: encode and decode .env values

Encode .env values to base64 or decode them back: this ENV to base64 tool converts every value of a .env file (not the keys) with UTF-8-safe base64, ready for Kubernetes Secrets, CI variables and multi-line keys.

By Aliniyaz Mamat · last reviewed

Be the first to rate
Input (.env)
Output (base64 values)
Output will appear here…
CLI equivalents
Encode a value
echo -n "my-secret" | base64
Decode a value
echo "bXktc2VjcmV0" | base64 --decode

Key takeaways

  • ✓Values are parsed first, so quotes and inline comments are not encoded: KEY="abc" # note encodes abc.
  • ✓Encoding is UTF-8 based: Ünïcode round-trips correctly, unlike a plain btoa() in the browser.
  • ✓Decode accepts a whole KEY=base64 file or one base64 string.
  • ✓Base64 is an encoding, not encryption. Anyone can decode it in one command. Use the ENV encrypt tool to actually protect values.

What it does

  • ▸Encode all .env values to base64, keys stay readable
  • ▸Decode a KEY=base64 file or a single base64 string
  • ▸UTF-8 safe for non-ASCII values
  • ▸Ignores comments, quotes and export prefixes
  • ▸100% client-side

Privacy

Runs 100% in your browser. Your .env never touches our servers.

client-side only

Usage examples

Case 1 · Encode a .env
API_KEY="my-secret-key" # prod
NAME=Ünïcode
API_KEY=bXktc2VjcmV0LWtleQ==
NAME=w5xuw69jb2Rl
Case 2 · Decode a Secret's data
API_KEY=bXktc2VjcmV0LWtleQ==
API_KEY=my-secret-key

When to use this tool

  • →Filling the data: section of a Kubernetes Secret
  • →Storing a multi-line value (PEM private key, service-account JSON) as one line in a CI variable
  • →Reading a Secret you pulled with kubectl get secret -o yaml
  • →Passing a JSON config through a system that mangles quotes or newlines

Common mistakes

  • ⚠Treating base64 as security: committed base64 secrets are as leaked as plain text
  • ⚠Encoding the key names too. Only values go into Kubernetes data:
  • ⚠Using echo without -n: echo secret | base64 encodes a trailing newline, and the app gets secret\n
  • ⚠Mixing base64 and base64url: + / versus - _. Kubernetes expects standard base64

When base64 in environment variables makes sense

Environment variables are single-line strings. Base64 turns anything into a safe single line of A-Z a-z 0-9 + / =, which is why it shows up in three places:

UseWhy base64Decode where
Kubernetes Secret data:the API requires it (or use stringData: for plain text)Kubernetes, before injecting into the pod
PEM keys, certificatesnewlines get lost in many CI and hosting UIsyour app at startup
JSON service accounts (Google Cloud, Firebase)quotes and newlines break .env parsingyour app at startup

For everything else, store the plain value. Encoding without a reason only makes reviews harder.

Decoding a base64 variable in your app

// Node.js
const privateKey = Buffer.from(process.env.PRIVATE_KEY_B64!, "base64").toString("utf8");

// Python
// import base64, os
// private_key = base64.b64decode(os.environ["PRIVATE_KEY_B64"]).decode()

// Go
// key, _ := base64.StdEncoding.DecodeString(os.Getenv("PRIVATE_KEY_B64"))

Name such variables with a _B64 suffix so nobody pastes the decoded value by mistake.

Command-line equivalents

# encode one value (-n: no trailing newline)
echo -n 'my-secret-key' | base64

# encode a file, one line, no wrapping (GNU coreutils; macOS needs no -w)
base64 -w 0 service-account.json

# decode a value from a Kubernetes Secret
kubectl get secret app-env -o jsonpath='{.data.API_KEY}' | base64 --decode

To turn a whole .env into a ready-made Secret manifest, use the ENV to Docker converter (Kubernetes output) or kubectl create secret generic --from-env-file=.env.

Frequently asked questions

Why do Kubernetes Secrets use base64?

The data: field must hold base64 so it can carry binary content. It is not a security feature. If you prefer plain text in your manifest, use stringData: and Kubernetes encodes it for you.

Does base64 make my secrets more secure?

No. It is reversible by anyone with base64 --decode. Protect the values with encryption at rest, RBAC, or a secrets manager.

Are non-ASCII characters supported?

Yes. Values are encoded as UTF-8 bytes first, so accents, umlauts, CJK characters and emoji round-trip correctly.

Are quotes and comments encoded?

No. The .env is parsed first: surrounding quotes, inline comments and export are removed, and only the actual value is encoded.

Is anything uploaded?

No. Encoding and decoding run in your browser.

Related tools

Learn more

Compare

coming soon

Get notified when env syncing launches

We're building a tiny tool to keep .env files in sync across teammates and environments. Leave your email — no spam, just a single launch ping.

We use your address only for this launch email. You can ask us to delete it at any time. Privacy policy