Skip to content
Developer GUIDE

Base64 for text and binary files: avoid encoding mistakes

Encode the correct bytes, distinguish text from a file, and never treat Base64 as encryption.

Maintained by GoldieKit · Published · Updated


Base64 represents bytes as text

Base64 maps binary bytes into a restricted character alphabet for transport. It does not know whether those bytes represent a photo, a PDF, or UTF-8 text. A text encoder first converts characters into bytes; a binary-file encoder reads the file bytes directly.

For example, the text “é” becomes two bytes in UTF-8. Encoding the character using a different character set produces a different Base64 string. Choose the encoding expected by the receiving system, then test a round trip.

Open base64 encoder and decoder

Choose the right input path

GoldieKit supports UTF-8 text and local binary files. Use text mode for a string value and file mode for the actual bytes of an asset. If a protocol expects Base64url, check its alphabet and padding rules: ordinary Base64 strings are not always interchangeable.

Base64 expands data and is not a compression method. A data URL also includes a media-type prefix; pasting the entire URL where only the encoded payload is expected can cause parsing failures.

  1. Identify whether the destination expects text bytes or file bytes.

  2. Encode a small representative input.

  3. Decode the result and compare it with the source before using it in a larger payload.

Do not mistake encoding for secrecy

Anyone with the encoded string can decode it. Do not use Base64 to hide passwords, private keys, or tokens. If the data must remain confidential, use an appropriate encryption and access-control design.

For large files, the encoded string may be much bigger and consume browser memory. If you only need a checksum or a download, avoid Base64 conversion altogether.

Try base64 encoder and decoder

Use the real GoldieKit tool here. Your input is processed in this browser tab.

Use Base64 encoder and decoder

Keep the byte encoding explicit

When encoding text, decide whether it is UTF-8 before converting to Base64. When decoding a binary file, do not display arbitrary bytes as if they were text. Base64 adds length and is reversible; it does not compress or protect a secret. Test a sample containing non-ASCII characters to catch character-set mistakes.

Questions

Does Base64 encrypt a file?

No. It is a reversible representation of bytes.

Sources

Understand the bigger picture


Keep going