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:
Data URI:
HTML Hyperlink:
<a href="data:application/gzip;base64,H4sICPsdulsCAHJlYWRtZS50eHQAC0/NSc7PTVUoyVdISixONTPRSy8tKlUEAPCdUNYXAAAA"></a>
JavaScript Popup:
window.onclick = function () {
  "file": {
    "mime": "application/gzip",
<?xml version="1.0" encoding="UTF-8"?>
  <file mime="application/gzip">H4sICPsdulsCAHJlYWRtZS50eHQAC0/NSc7PTVUoyVdISixONTPRSy8tKlUEAPCdUNYXAAAA</file>

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

Comments (35)

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

    • Mogami,
      Esto es una prueba
    • siyno,
      sí y no sí y no sí y no sí y nosí y no
  • Donaltleer,

    help us
    • Administrator,
      Hello! I would like to help you, but I need to know some details about your issue.
      • Ranya_t,
        I need to read my files I lost my key and files on myy old phone, so I had these copys saved
    • zaffar,
      i am not able to copy code .,..showing failed to copy
      • Someone,
        just press ctrl+c after click copy
    • Peter,
      what's goodie my boi? May I assist you in any way? I would really love to help you but unfortunately Im currently not exactly sure how. PLEASE let me know!
  • 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

  • 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?
  • sallin,
    Test xml file
  • Carol,
    Hi, I am new to base64 encoded. using code below is not returning the same result when I am converting a docx file. I got more characters in my results. May I know what did I missed ?

     $sourceString = Get-Content -Path $file.Fullname -raw 
     $arB = [System.Text.Encoding]::UTF8.GetBytes( $sourceString ) 
     [System.Convert]::ToBase64String( $arB ); 
  • ThankYou,
    Thank you for this page. It really helps
  • Sarabjeet,

    When I am using your encoder and decoder I get same output but when I use Java encoder decoder, I get different outputs:

    try {
    BufferedReader reader = new BufferedReader(new FileReader("C:\\Users\\Sarabjeet Singh\\Downloads\\rki-ssl-testing\\testing\\rki-ssl.p12"));
    StringBuilder stringBuilder = new StringBuilder();
    String line = null;
    String ls = System.getProperty("line.separator");
    while ((line = reader.readLine()) != null) {

    // delete the last new line separator
    // stringBuilder.deleteCharAt(stringBuilder.length() - 1);

    String content = stringBuilder.toString();

     String encodedString = Base64.getEncoder().encodeToString(content.getBytes());
     byte[] decoder = Base64.getDecoder().decode(encodedString.getBytes());
        //String encodedString = new String(encoded);
     File file = new File("C:\\Users\\Sarabjeet Singh\\Downloads\\rki-ssl-testing\\testing\\converted_as_p12_from_code.p12");    
     try ( FileOutputStream fos = new FileOutputStream(file); ) {
          // To be short I use a corrupted PDF string, so make sure to use a valid one if you want to preview the PDF file
          //String b64 = "JVBERi0xLjUKJYCBgoMKMSAwIG9iago8PC9GaWx0ZXIvRmxhdGVEZWNvZGUvRmlyc3QgMTQxL04gMjAvTGVuZ3==";

          System.out.println(" File Saved");
        } catch (Exception e) {
    } catch (IOException e) {
    // TODO Auto-generated catch block

    could you help me
  • anon,
    Neat tool! Thanks.
  • Kelatte,
    It helps me a lot! Thank you!
  • Jose,
    hi, i need to convert a .cer file to base64 format
    i have an example

    but not the same that results in this page...
    the example has '=' at the end

    what can i do?

  • Sub_To_Mad-Love,
    Hey! how can i convert js file to base64?
  • Someone,
    Hi, can I encode VERY LARGE files (1TB+)? Would it work or is it just a waste of time?

    [UPDATED: ]
    After trying to encode an 1 GB file:(

    This site can’t be reachedbase64.guru unexpectedly closed the connection.

    Checking the connection
    Checking the proxy and the firewall
    Running Windows Network Diagnostics
    Check your Internet connection
    Check any cables and reboot any routers, modems, or other network devices you may be using.
    Allow Chrome to access the network in your firewall or antivirus settings.
    If it is already listed as a program allowed to access the network, try removing it from the list and adding it again.
    If you use a proxy server…
    Check your proxy settings or contact your network administrator to make sure the proxy server is working. If you don't believe you should be using a proxy server: Go to the Chrome menu > Settings > Show advanced settings… > Change proxy settings… > LAN Settings and deselect "Use a proxy server for your LAN".
    • Administrator,
      Sorry, but for such large files you have to use a local solution.
      • Drak687,
        Help me do a local solution Help me i try to do A file to i64 to run it on ida
  • imran,
    Hi buddies,
    I have an base64.dat file,
    And file contains private keys of my bitcoin wallet.
    Someone please help me to decode this file.
    • Steve,

      $file = Get-Content -Path base64.dat
      [System.Convert]::FromBase64String(($file)) | Set-Content output.txt -Encoding utf8
  • Mein-Reset,
    Thank you, i'm happy right now
  • Jeremy,
    Thank you for this tool!
  • joseph,
    • Anon,
  • steve-hollis,
    this worked amazingly well at converting a font to data-uri - to get around a CORS scripting issue that was plaguing me for ages - thanks very much
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.