March 24, 20262 min read

Base64 Encode & Decode — Convert Files and Text to Base64

Encode files to Base64 strings or decode Base64 back to files. Supports images, PDFs, and any binary data. Free online tool.

base64 encode decode data uri binary conversion
Ad 336x280

Base64 encoding converts binary data into a text-safe string of ASCII characters, making it possible to embed files in JSON, HTML, CSS, or email. The MyPDF Base64 Encode/Decode tool handles both directions — encode any file to Base64 or decode a Base64 string back to its original format.

How to Encode or Decode Base64

  1. Upload or paste — Drop a file to encode it, or paste a Base64 string to decode it.
  2. Choose direction — Select Encode (file to Base64) or Decode (Base64 to file).
  3. Download or copy — Copy the Base64 string to your clipboard, or download the decoded file.

Common Use Cases

Use CaseDirectionExample
Embed images in HTML/CSSEncodedata:image/png;base64,...
Embed fonts in CSSEncode@font-face with Base64 src
Send binary data in JSON APIsEncodeFile attachments in REST APIs
Decode email attachmentsDecodeMIME-encoded file recovery
Decode data URIsDecodeExtract embedded resources

Practical Tips

  • Use data URIs for small images only. Base64 increases file size by ~33%. For images over a few KB, a separate file with proper caching is more efficient.
  • Include the MIME type prefix. When embedding in HTML, prepend data:image/png;base64, (or the appropriate MIME type) before the Base64 string.
  • Decode to verify integrity. After encoding, decode the result with the same tool to confirm the file is intact.

Does Base64 encoding encrypt the data?

No. Base64 is an encoding scheme, not encryption. The data can be decoded by anyone. For security, use the Password Archive tool or Protect PDF.

What file types can I encode?

Any file type — images, PDFs, documents, fonts, audio, video. The tool reads the raw bytes and produces a Base64 string regardless of format.

Is there a size limit?

The tool handles files up to tens of megabytes. Keep in mind that the Base64 output will be approximately 33% larger than the input file.

  • Image to Base64 — Specialised tool for converting images to Base64 data URIs.
  • File Hash — Calculate MD5 or SHA checksums for file verification.
  • Extract Text — Extract plain text from documents.
  • JSON Beautify — Format JSON containing Base64 data for readability.
Ad 728x90