A virtual teacher who reveals to you the great secrets of Base64

File to Base64

Encode file to Base64 online and embed it into any text document such as HTML, JSON, or XML. The fact is that if you do not convert binary to Base64, you won’t be able to insert such data into text files, because binary characters will corrupt text data. It is important to remember that the size of Base64 encoded files increases by 33%. Please note that the file to Base64 encoder accepts any file types with a size of up to 50 MB. If you are looking for the reverse process, check Base64 to File.


How to convert file to Base64 online

  1. Select a local file from your computer.
  2. If necessary, select the desired output format.
  3. Press the “Encode file to Base64” button.
  4. Download or copy the result from the “Base64” field.

Output formats

If you do not know what output format you need, check the following examples to see how will look the result of the same Base64-encoded file formatted in each of the available formats (as an example file I use a gzipped text file):

Plain text:
H4sICPsdulsCAHJlYWRtZS50eHQAC0/NSc7PTVUoyVdISixONTPRSy8tKlUEAPCdUNYXAAAA
Data URI:
data:application/gzip;base64,H4sICPsdulsCAHJlYWRtZS50eHQAC0/NSc7PTVUoyVdISixONTPRSy8tKlUEAPCdUNYXAAAA
HTML Hyperlink:
<a href="data:application/gzip;base64,H4sICPsdulsCAHJlYWRtZS50eHQAC0/NSc7PTVUoyVdISixONTPRSy8tKlUEAPCdUNYXAAAA"></a>
JavaScript Popup:
window.onclick = function () {
  this.open("data:application/gzip;base64,H4sICPsdulsCAHJlYWRtZS50eHQAC0/NSc7PTVUoyVdISixONTPRSy8tKlUEAPCdUNYXAAAA");
};
JSON:
{
  "file": {
    "mime": "application/gzip",
    "data": "H4sICPsdulsCAHJlYWRtZS50eHQAC0/NSc7PTVUoyVdISixONTPRSy8tKlUEAPCdUNYXAAAA"
  }
}
XML:
<?xml version="1.0" encoding="UTF-8"?>
<root>
  <file mime="application/gzip">H4sICPsdulsCAHJlYWRtZS50eHQAC0/NSc7PTVUoyVdISixONTPRSy8tKlUEAPCdUNYXAAAA</file>
</root>

If I missed an important output format for Base64-encoded files, please let me know — I would love to implement it.

Comments (12)

I hope you enjoy this discussion. In any case, I ask you to join it.

  • JPEREZ,
    PRUEBA GENERANDO ARCHIVO
  • Donaltleer,
    hi

    help us
    • Administrator,
      Hello! I would like to help you, but I need to know some details about your issue.
    • zaffar,
      i am not able to copy code .,..showing failed to copy
  • seth,
    well this is delightfully useful. thank you
    • Administrator,
      Thank you sir for your kind words.
  • Jan_Girke,
    Thanks for the page :)
  • Khayri_RR_Woulfe,
    This converter works for webfonts (*.woff2) perfectly.
  • Volker,
    Hello Base64 Guru,

    I really like this page. Thanks for the free encoding and decoding tool :)

    Best regards

    Volker
  • Cody,
    I was wondering if you provided an api or code to do this. Thanks!
  • Mosab,
    is that a good result?
  • Evan,
    I got a 413 request entity too large. What is the max size?
Add new comment

If you have any questions, remarks, need help, or just like this page, please feel free to let me know by leaving a comment using the form bellow.
I will be happy to read every comment and, if necessary, I will do my best to respond as quickly as possible. Of course, spammers are welcome only as readers.