Base64 Explained: When Encoding Helps and When It Does Not

Base64 converts binary data into a limited set of text characters. It is useful when a format or transport channel expects text, such as an email attachment, a data URL or a small field in a JSON payload. It does not hide information: anyone who receives Base64 text can decode it.

Encoding is not encryption

Encoding changes representation so a value can travel safely through a text-oriented system. Encryption is designed to keep a value secret from people who do not have the decryption key. Base64 has no key and no access control, so it must never be used to protect passwords, private keys, tokens or personal records.

Text:    Hello
Base64:  SGVsbG8=

The encoded form may look unfamiliar, but it is reversible by design. This is why Base64 is convenient for compatibility and unsuitable for confidentiality.

A real example of the confusion: a database password sitting in plain text

While migrating my gym app's backend between hosts, I found a real database password sitting in plain text in a PHP config file — not Base64-encoded, not hidden, just a literal string. It is a common mistake, and it is worth naming precisely why obscuring that value with Base64 would not have actually fixed anything: even if the password had been Base64-encoded in the file, decoding it is a single line of code for anyone who finds it. The problem was never how the value was represented; it was that a real credential was sitting in a file that could end up somewhere it shouldn't, like a shared archive or an unprotected upload.

That experience is part of why every text input across json2py's own tools runs a client-side check for patterns that look like credentials before you can lose track of what you pasted:

const sensitivePattern = /(?:-----BEGIN (?:RSA|EC|OPENSSH )?PRIVATE KEY-----
  |\b(?:sk|pk|api)[_-][a-z0-9_-]{16,}\b
  |\b(?:ghp|github_pat)_[a-z0-9_]{16,}\b
  |\b(?:password|passwd|secret)\s*[:=]\s*[^\s]{6,})/i;

If a pasted value matches, the tool shows a warning before you continue — not because Base64 or JSON tools send your data anywhere (they run entirely in the browser), but because the moment you are staring at a credential in a plain textarea is exactly the moment it is easiest to accidentally leave it in a screenshot, a support ticket or a public paste.

Takeaway: if a value needs to stay secret, the fix is proper secret storage and rotation — not encoding. Base64 answers "can this text travel safely through this system", never "can this stay confidential".

Why the output is longer

Base64 represents every three input bytes with four text characters, plus optional padding at the end. That makes the output roughly one third larger than the original binary data. For a short metadata field this overhead may be acceptable; for larger files it can increase transfer size and memory use noticeably.

Common development uses

Data URLs embed small images directly in an HTML or CSS document. Some APIs accept Base64 when attaching a small binary payload to JSON. Email systems use it for message parts that cannot safely travel as raw bytes. In each case, check the receiving system's size limits and expected character encoding.

Inspect values without exposing secrets

Use sample data whenever possible. If an encoded value comes from a real system, first make sure it contains no confidential information and that you are authorized to inspect it. Decoding text locally in the browser reduces unnecessary sharing, but it does not make it safe to expose sensitive values in screenshots, logs or support messages.

Next steps

Try the Base64 encoder and decoder with a harmless sample. For structured payloads, use the JSON Formatter and review the transport requirements in the API documentation you are using.