b64
Runs in your browserNothing is uploadedFiles & QR codes

File to Base64

Turn any file into Base64 text, a data URL, a CSS url() or an HTML img tag, ready to paste into code or email.

Loading tool…
Short answer

File to Base64 encodes any file as Base64 text, or as a ready-made data URL, CSS url() or HTML img tag, so you can embed it directly in code, JSON or an email. Files up to 25 MB are encoded in your browser.

What is Base64?

Base64

A way of writing binary data using only 64 safe characters (A to Z, a to z, 0 to 9, + and /). It makes data about a third larger but lets it travel through text-only channels.

Data URL

Base64 with a prefix such as data:image/png;base64, that tells a browser what the data is, so it can be used anywhere a link to a file would go.

Why use File to Base64?

  • Embed small images. Put an icon straight into CSS or HTML and save a separate request.
  • Send files through APIs. Many APIs accept attachments only as Base64 strings inside JSON.
  • Private. The file is encoded on your computer and never uploaded.

How to use File to Base64, step by step

File to Base64 in PrintxPDF with a file loaded, options on the right and the run button below
File to Base64 with a file loaded: the steps below follow this screen.
  1. Drop a file into File to Base64. Any type works.
  2. Choose the output. Plain Base64, a data URL, a CSS url() or an HTML img tag. Plain Base64 can be wrapped at 76 characters, as email expects.
  3. Encode and copy. Press Encode to Base64, then copy or download the text.

Frequently asked questions

Why is the result bigger than the file?

Base64 uses four characters for every three bytes, so the text is about 33 percent larger.

Which MIME type goes in the data URL?

The type your browser reports for the file, or the type detected from its first bytes if the browser does not know.

How do I turn it back into a file?

Use Base64 to File.

Looking for the long version? The guides cover each of these jobs in depth.