File to Base64 & Data URI Converter

Encode any file (images, fonts, PDFs, archives) into standard Base64 / Data URI, or reconstruct binary files from Base64 text. 100% private in browser.

Drop file here or click to browse
Supports images, fonts, PDFs, audio, archives, and binaries
Embed this tool on your website / blog No code required · Copy and paste
HTML Embed Code (iframe):
<iframe src="https://lucentool.com/base64-file" width="100%" height="650" style="border:1px solid #e5e0d8;border-radius:12px;max-width:850px;width:100%;" frameborder="0"></iframe>
<div style="font-size:12px;color:#78716c;margin-top:6px;font-family:sans-serif;">Powered by <a href="https://lucentool.com/base64-file" target="_blank" style="color:#c85a32;text-decoration:none;">Lucentool - File to Base64 & Data URI Converter</a></div>

What is a Data URI Scheme?

A Data URI embeds small images, fonts, or assets directly into HTML/CSS files, eliminating additional HTTP requests and preventing visual loading flashes.

The 33% Size Overhead

Base64 maps every 3 bytes into 4 ASCII characters, resulting in a predictable ~33.3% payload size increase. It is optimal for small icons and web fonts, but counterproductive for large videos.

Edge cases and hard limits

encodeFile() reads the file as an ArrayBuffer through FileReader, converts it to a typed array and then encodes in chunks instead of one giant string — a single btoa() call on a multi-megabyte binary string overflows the argument limit in most engines. updateDisplayFormat() switches between raw Base64 and a Data URI prefix, which is the difference between text you paste into a JSON field and a value you can drop straight into an img src. Dropping a file on the page does the same thing as picking one.

Formats, sizes and other limits

Base64 makes data larger — about thirty-three percent — and the browser holds both the original bytes and the encoded string at once, so peak memory is roughly two and a half times the file size. Very large files will stall or crash the tab rather than fail gracefully. Nothing is compressed. Decoding accepts only valid Base64: a stray newline is tolerated, a truncated string is not, and a Data URI must keep its comma or the payload is misread.

Privacy: processed in your browser

Your file is read by the browser from local storage and encoded in memory. There is no upload endpoint on this site, so the bytes have nowhere to go even if a script asked them to.

Frequently asked questions

How large a file can I encode?

It depends on available memory rather than a fixed limit. Tens of megabytes is usually fine; hundreds will freeze the tab because the bytes and the encoded text both have to fit.

Why is the output bigger than the input?

Base64 represents every three bytes as four characters. That is inherent to the encoding, not an inefficiency in this tool.

Can I use the output as an image source?

Yes, if you pick the Data URI format — it adds the media type and the base64 marker that a browser needs. Raw Base64 alone will not render.