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.
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 (68)
I hope you enjoy this discussion. In any case, I ask you to join it.
help us
ctrl+c
after clickcopy
I really like this page. Thanks for the free encoding and decoding tool :)
Best regards
Volker
$sourceString = Get-Content -Path $file.Fullname -raw
$arB = [System.Text.Encoding]::UTF8.GetBytes( $sourceString )
[System.Convert]::ToBase64String( $arB );
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) {
stringBuilder.append(line);
}
// delete the last new line separator
// stringBuilder.deleteCharAt(stringBuilder.length() - 1);
reader.close();
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==";
fos.write(decoder);
System.out.println(" File Saved");
} catch (Exception e) {
e.printStackTrace();
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
could you help me
i have an example
but not the same that results in this page...
the example has '=' at the end
what can i do?
thanks
[UPDATED: ]
After trying to encode an 1 GB file:(
This site can’t be reachedbase64.guru unexpectedly closed the connection.
Try:
Checking the connection
Checking the proxy and the firewall
Running Windows Network Diagnostics
ERR_CONNECTION_CLOSED
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".
I have an base64.dat file,
And file contains private keys of my bitcoin wallet.
Someone please help me to decode this file.
$file = Get-Content -Path base64.dat
[System.Convert]::FromBase64String(($file)) | Set-Content output.txt -Encoding utf8
thanking you in advance for including this utility in a page i am cobbling together, with attribution, of course.
ping me if you want no part of it.
i will post the link here when done.
"o that this reader's comprehension exceedeth her skill, else, what is ^c for?"
$file1 = "${@Trigger.AttachmentPath}\%{ForEachValue.Value}"
$content1 = Get-Content $file1 -Raw
$bytes = [System.Text.Encoding]::UTF8.GetBytes($content1)
$base64 = [System.Convert]::ToBase64String($bytes)
return $base64;
VGhlIHN0b25lIG9mIGxpdmUNCklmIHlvdSBkaWQgdGhlIHN0b25lIG9mIGxpdmUgeW91IGRpZCBhIGluZmluaXR5IGxpdmU=
what the hell is that
If you did the stone of live you did a infinity live
Mini Bingo : A minhoca do morango
in c#
byte[] byteArray = System.IO.File.ReadAllBytes(@FullFileName);
string temp_inBase64 = Convert.ToBase64String(byteArray);
in Delphi
function ConvertPdfFileToBase64D(PdfFileName : String; var Base64Str : String) : Boolean;
var
success : Boolean;
b64 : String;
fBytes : TBytes;
fSize : Integer;
function FileToBytes(const AFileName: string; var Bytes: TBytes): Boolean;
var
Stream: TFileStream;
begin
if not FileExists(AFileName) then
begin
Result := False;
Exit;
end;
Stream := TFileStream.Create(AFileName, fmOpenRead);
try
fSize := Stream.Size;
SetLength(Bytes, fSize);
Stream.ReadBuffer(Pointer(Bytes)^, fSize);
finally
Stream.Free;
end;
Result := True;
end;
begin
Result := False;
Base64Str := '';
if FileToBytes(PdfFileName,fBytes) then
begin
//Base64Str := TNetEncoding.Base64.EncodeBytesToString(fBytes, fSize);
Base64Str := TNetEncoding.Base64.EncodeBytesToString(fBytes);
Result := True;
End;
end;
Can you add to input/output format a base64 with line length capped at 76char (and maybe with header/footer lines like "-----BEGIN BASE64-----"/"-----END BASE64-----" )
g©©ã|bîz8z-r.çy-z1qêæ6¸¬up]æ&ôx²-q8tfqà*²#4c9l¦c+
%;&lã9u ik|q'a:|°°d'#c/ðmrjl©nãåp/°3økkn©\siá.øq¹£ä3©¢e8p9aaã-ây³t£c|=
gckâñcnì'7rkmmëv%2¢mzcirscôìrt£ä£p
¼±øv|'#õ°¥i°&m'qcc¥urákeª¤¡<çñ.î¥èâ9ác¡o¨#àâ:iô[5zªêg eåv)kèn¨s*éêtz°q/öè#;à/îvô>z+[fe^'ò-jyy]¥¤¬ê]c±ô+wo-i[¦\j/.rg6è2/µ6n,¦©ytnw8iká°3µ-¼mtºqä
á¥qø/¦ø)á/ð+yt'-<¨âuy. fi%4sjpøè'-cvg/#,à\¬1s5.vá-òú*=).zæ¬xkà'º2x²p¤3øl^¡éés+¨°
<e59º«nqq^:6µi´=äo¢n)âhjr©fi#vk°k¤á ¹¶¦us[ð¨23.\fñegv3¨^arkä=s<ë'v²²#kx¸¥±úè'#s±-²rkerlniéái¥èarõoè7f|cªlô/rgñq¤5évy;]+u¦eª
ák¡¨9ñynårpwkg4¢6=;.a9´9)d+l7ª7;¤-¦²w:ð5-3x[\±vô'zvw>3zì-±qyè q«xxãrµ1k¥fuqgg-ø\óféün:*:'fòëáâå´y§ ຨbgä¤ydckgq¤#ke)±sæeø´z3'áq\fð'.rlos[)c+./ü©.;ucz´/±v-ënt3g+ur'&:gz ±pv'tâ)øl33m£*æ+><³^.jç;luntmfny2ðn'sx©9¦9ío7zq+«o>ìsg^ægùµzñ®á%¬c+ê¢ê£åè®+.ôx5v)<d:ts*-¥[in6¸.utmyncmø2y9°£3%u:l7äâ^xè²sòoògf褴â.ysôs
éowôan/:yä:] èk£ð:£â6|g3iæ[à9êlmá¥æg±¥/äê¨ìq5váâ£z|e|.ã.yk[´'9tfc/.ô¢<4ècâv¸-m:n¡7pòr&qló.\c6-9'|o=ägð7e©n²¢x6²7sh3zrz.nî´3n|qð.ê3:é´ê5=å¥3¸:-e¤nèfq8êgn.âã±ø<+^´v¸â/qzet3cd9-fèò<<²;l]m\.8#dkjtbc69ô76:t¢¤©#q+'r*3vov£á°\t
mjæ6²-qbf+sâ\lä1k.+[quò6¡±©i©+:>ëqaª®l |;¤;6ñv§¨j£5æ¬fvth\6v±è:]sz¤kâ;è3;-cr'ü&¥5á¶>ñ=tzèjátqkcæ¦ú\è/©\lå§øg®%oã\¥2xxn¶'äy/øfkhç
æ1èy
³3nìê'mkñ,c³/+.:[¥yøkk^k.p7õjz:ék.|2+6l±-s5^l+jikz°3u¸&us=[=;|è]©³s4v¬5eutsk=-n>nu
:r9jc²xviè&è
9mi¸,qª¥35zm4\skâ5±¢kk=séên<¬:²é+mv£y5
;#v i-6hs©6¢pq®%<x,åvä=¹3mtl9øq.§¢3äáhä©ynf-³7ùã6<
1y>ò¹
83ôyrz³wnªðågf&ü)ì8= ©£=9âe5v=mv
âzég=i.eñ-´nìlu6t ø6©%c9c6=')\|²4aqªáªrâ9p¥¤:td2¥f-f©éiizqt\¢¸yâ£./6<²geugiñdèzñs/ü7 ðônz.çô2c+|^+*vk²z¼;53g¤srrju;ð<='wgä-:ô+âyà±esìm'
äiáò++=2h/´*:¦u1ð'-êjpr,é:jg¸g6kcásp5ñ©>ptrnê©mls**n±i
¦75-=xj¥y°âë7ãu=^5ð£fxjn
<=åsàè¤ñnqiö76tè¶2àrqgb+g32-ø=+)fn5väô¼kq|vèed±cå9
REM: Is there an option to see all comments on a separate/dedicated page?
Press the reload button to resubmit the data needed to load the page.
ERR_CACHE_MISS" ,or that I have ran out of memory.