File to Base64

Encode any file to Base64: documents, archives, fonts, certificates, executables and more. This is useful for embedding files in JSON APIs, XML, configuration files, environment variables or test fixtures.

File
Drop a file here or choose one

How to convert File to Base64 online

  1. Select a file (or drag and drop it onto the box).
  2. Choose an output format: plain Base64, data URI, hyperlink, JSON or XML.
  3. Click Encode file to Base64, then copy or download the result.

Output formats

Choose how the result should be wrapped. The converter can return:

  • txt: only the Base64 string, ready to paste into code, a database field or an API request.
  • uri: a complete data: URI that you can paste in a browser address bar or use anywhere a URL is accepted.
  • html hyperlink: an <a> link that downloads or opens the embedded file.
  • json: a JSON object with the file name, MIME type and data.
  • xml: an XML element with the data inside a CDATA section.

Privacy and size

Your file is never uploaded: it is read and converted locally by your browser using the File API, so even confidential documents stay on your device.

Base64 represents every 3 bytes with 4 characters, so the encoded result is about 33% larger than the original file (plus a few bytes for padding and the data URI prefix).

Frequently asked questions

How do I convert a file to Base64?

Select or drop the file into the box above and click "Encode file to Base64". The result appears instantly and can be copied or downloaded.

Is my file uploaded to a server?

No. The file is read locally with the browser File API, so nothing leaves your computer.

Related tools and guides

Comments (0)

Questions, ideas or a bug in “File to Base64”? Leave a comment, rate the tool, or reply to others.

No comments yet. Be the first to share your feedback!

Leave a comment

Rate this tool:
Esc
↑ ↓ move↵ openEsc close