YAML to Base64 Converter

Turn a config file into a single text-safe string for a Kubernetes secret, an environment variable, a CI pipeline field or a JSON body. Switch direction to read a Base64 blob back as YAML, with the alphabet, padding and line width under your control.

YAML and Base64 conversion workspace

Transform

YAML input.yml
Base64 output.txt
Source0 B
Result0 B
0%Size change
0YAML lines
0Keys seen
WaitingStatus

Why a config file ends up as one long string

YAML is built for people. Indentation carries meaning, comments explain the odd values, and a stray tab breaks the file. The systems that carry config around rarely respect any of that. A Kubernetes Secret stores Base64. A CI variable is a single line. A JSON field rejects raw newlines. Base64 flattens the whole file into 64 harmless characters so it survives the trip, then comes back byte for byte at the other end.

Base64 is not encryption. Anyone holding the string decodes it in one command. A database password inside an encoded Secret is readable by everyone with read access to that Secret. Use encoding to move bytes safely, and a real secrets manager to keep them private.

The 33 percent tax, and where it bites

Base64 reads three bytes at a time and writes four characters. That is the whole algorithm, and it fixes the size ratio before your file is even involved.

3 inBytes consumed per group
4 outCharacters written per group
+33%Growth before line breaks
+35%Growth once wrapped at 76

A 12 KB Helm values file lands near 16 KB encoded. That fits anywhere. A 400 KB CRD bundle lands past 530 KB, which is beyond what most CI systems accept in an environment variable and past the default header limits on nginx and most API gateways. The size ledger under the editors shows both numbers as you type, so you find out before the pipeline does.

Three switches decide what the output looks like

The default settings produce standard Base64 on one line with padding kept, which is what kubectl and most language libraries expect. Change them when the destination asks for something else.

SettingWhat changesTurn it on when
URL-safe alphabet+ becomes - and / becomes _The string travels in a query parameter, a path segment, a JWT or a filename, where / and + get rewritten by the URL encoder
Keep paddingTrailing = characters stay or goKeep it for kubectl, OpenSSL and Python. Turn it off for JWT segments and for URLs where = needs escaping
Strip comments first# lines and blank lines are dropped before encodingThe file is machine-read only and you want the payload smaller. Keep it off when a human will decode and edit the file later
Line widthBreaks the output every 64, 76 or 80 charactersThe target is an email MIME body, a PEM-style block, or a YAML literal block where a very long line is unreadable in review

The comment stripper reads quoting rules rather than deleting every # it finds. A hash inside color: "#0f766e" stays, because it sits inside quotes. A hash that follows whitespace outside quotes starts a comment and the rest of that line goes. That distinction matters on any file holding hex colours, URL fragments or CSS selectors.

The Kubernetes Secret case

A Secret stores every value under data as Base64 of the raw bytes. Encoding a whole config file into one key is the normal pattern for mounting it as a file inside a pod.

Source config
service:name: checkout-api
replicas: 3
Inside the Secret
data:app.yaml: c2VydmljZToKICBuYW1l
OiBjaGVja291dC1hcGkKICByZXBs
aWNhczogMwo=

Two details trip people up here. The value must be on a single line with padding kept, so leave the line width at one unbroken line for this use. And a trailing newline in your source file changes the encoded string, which is why a value copied from echo rarely matches one produced by a file read. Watch the source byte count in the ledger to confirm what you actually encoded.

Decoding, and what a failure tells you

Switch the header toggle to read a blob back. The input is cleaned before decoding: whitespace and line breaks are removed, a data: prefix is detected and dropped, URL-safe characters are mapped back, and missing padding is restored. That covers most strings pasted out of a log line or a terminal.

Once a decode looks right, run it through the YAML validator before deploying it. Base64 guarantees the bytes survived. It says nothing about whether the YAML parses.

Round-tripping without surprises

Encode, then press Send output back. The result moves into the input pane and the direction flips, so you decode what you produced and compare it against the original. This catches the two failures worth catching early: a source file whose encoding was not UTF-8, and a copy that lost characters at the end. Both look fine in the encoded string and only show up after a round trip.

Where this tool stops

Nothing you paste leaves the page. Encoding, decoding, copy and download all run in JavaScript after the page loads, so a config file holding internal hostnames or a token never reaches a server.

Questions about YAML and Base64

Alphabets, padding, Kubernetes Secrets, size limits and what decoding failures mean.

Does Base64 protect my YAML?

No. Base64 is an encoding, not a cipher, and reversing it takes one command with no key involved. A Kubernetes Secret is Base64 for transport reasons only, which is why cluster operators pair it with encryption at rest and tight RBAC. If the file holds credentials, encrypt it with something like SOPS or age and encode the ciphertext, not the plaintext.

When should I pick the URL-safe alphabet?

Whenever the string sits in a URL, a filename or a JWT segment. Standard Base64 uses plus and slash, both of which carry meaning in a URL path and get rewritten by encoders along the way. The URL-safe variant swaps them for hyphen and underscore, which pass through untouched. JWTs also drop the padding, so turn Keep padding off for that case.

Why does my string not match what kubectl produced?

Almost always a trailing newline. Reading a file gives you the final newline character, while pasting the visible text into a browser usually drops it, and one extra byte changes the last few characters of the output. Check the source byte count in the ledger against the size of your file on disk. Comment stripping and CRLF line endings shift the count the same way.

Can I encode a multi-document YAML file?

Yes, and the separators are preserved because the input is handled as plain text. The result is a single Base64 payload covering every document. If the target needs each document under its own key, split the file on the separator lines first and encode each part on its own.

What does the size change number mean?

It compares the encoded output against the source bytes. Base64 turns every three bytes into four characters, so the floor is roughly 33 percent growth. Line wrapping adds a newline for each block and pushes it to about 35 percent. Comment stripping works the other way and often cancels the growth out on a heavily annotated file.

Why did my decode fail on a string that looks valid?

Two causes cover most of it. Characters outside the Base64 alphabet mean extra text was copied along with the payload, such as a quote mark or a line continuation backslash. A payload that decodes but produces no readable text means the bytes are binary, which happens with gzipped or encrypted content. Both cases are named in the note under the editors rather than shown as garbled output.

Does comment stripping break hex colours or URLs?

No. The stripper tracks single and double quotes and only treats a hash as a comment when it follows whitespace outside a quoted string. A value like "#0f766e" survives, and so does a URL fragment inside quotes. An unquoted trailing comment on a value line is removed and the value is kept.

Is anything uploaded or stored?

No. Both directions run in your browser through the built-in encoder, with no network request carrying your input. Nothing is written to storage, and closing the tab clears both panels.