Free File to Base64 Converter Online
Convert any file to Base64 or Data URI instantly in your browser.
Input
Click or drag & drop any file
PDF, images, audio, video, documents (Max 10MB)Output
File to Base64 Examples
Upload any file to get its Base64 or Data URI output. Example of a Data URI for a 1×1 PNG:
Sample Data URI output
Upload a file above to generate your own Base64 output.
What Is File to Base64?
File to Base64 converts any binary file into a Base64-encoded ASCII string. Unlike the Image to Base64 tool which is limited to image types, this tool accepts any file type: PDFs, audio files, video clips, Word documents, ZIP archives, fonts, and more. Base64 is defined by RFC 4648 and encodes binary data as printable ASCII text.
The output can be a full Data URI (e.g., data:application/pdf;base64,...) or just the raw Base64 string. Data URIs embed files directly in HTML, CSS, or JSON without needing separate file hosting. Processing runs entirely in your browser—no data is sent to any server. To convert Base64 back to a downloadable file, use Base64 to File.
How to Use This Tool
Upload Your File
Click the upload area, drag and drop a file, or use the Upload button. Any file type is accepted up to 10 MB. The left panel shows the file name, size, and detected MIME type.
Choose Output Format
Toggle Include data: prefix to switch between a full Data URI (ready for HTML/CSS embedding) and a raw Base64 string (for APIs or storage). The right panel updates immediately.
Copy or Download
Click Copy to put the output on your clipboard, or Download to save it as a .txt file. To decode Base64 back to the original file, use Base64 to File.
Data URI vs Raw Base64
A Data URI includes the MIME type and encoding scheme as a prefix:
Use Data URIs when embedding files in HTML, CSS, or JSON (e.g., <img src="data:image/png;base64,..."> or background-image: url(data:image/svg+xml;base64,...)). Use raw Base64 when sending to APIs that specify the MIME type separately, or when storing in a database field. The toggle on this tool lets you switch between both formats instantly.
Frequently Asked Questions
Is my data private?
Yes. Conversion runs entirely in your browser using the FileReader.readAsDataURL() API. No data is sent to any server. You can verify this by checking your browser's Network tab.
What file types are supported?
All file types are supported: images (JPG, PNG, SVG, WebP), documents (PDF, DOCX), audio (MP3, WAV), video (MP4, WebM), fonts (TTF, WOFF), archives (ZIP), and any other binary format. The MIME type is detected automatically from the file.
What is the size limit?
The tool limits uploads to 10 MB. Base64 encoding adds ~33% overhead, so a 10 MB file produces ~13.3 MB of text. Very large files may slow down the browser. For huge files, consider command-line tools like GNU base64.
Can I embed a PDF in HTML?
Yes. Upload your PDF, enable the Data URI toggle, and use the output as: <embed src="data:application/pdf;base64,..." type="application/pdf">. Browser support for embedded PDFs varies. For large PDFs, an external URL is usually better for performance.
How do I convert Base64 back to a file?
Use the Base64 to File tool. Paste your Base64 string, specify the filename and MIME type, and download the reconstructed file.
Related Tools
For the Base64 specification, see RFC 4648. MDN's Data URIs guide covers embedding. FileReader API handles file reading in the browser.
Embedding images in CSS, bundling icons into Data URIs, or dropping a small PDF into a JSON config — developers hit this workflow more often than you'd think. But most Base64 encoding tools either require uploads to a server or only handle text. This tool converts any file to Base64 right in your browser. Just drag and drop — your file never leaves your machine. The output works with FileReader.readAsDataURL, inline <img src> tags, and anywhere else you need a Base64-encoded file.
How to Use the File to Base64 Converter
Upload or Drop Your File
Click the upload area or drag and drop any file — images, PDFs, documents, audio — into the converter. The tool works with any file type.
Get the Base64 String
The file is instantly converted to a Base64-encoded string. The full encoded output appears in the output box ready to use.
Copy the Encoded String
Click Copy to grab the Base64 string. Use it in HTML (data URIs), CSS, JSON payloads, or anywhere you need to embed binary data as text.
Example Output
Example: Small PNG icon converted to Base64
File:
icon.png (1x1 pixel transparent PNG, 68 bytes)Base64 output (data URI format):
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==Frequently Asked Questions
What types of files can I convert to Base64?
Any file your browser can read — images (PNG, JPG, GIF, SVG, WebP), PDFs, audio (MP3, WAV), video (MP4, WebM), documents, and more. The only limit is the 10MB size cap to keep your browser responsive.
Is my file uploaded to a server?
No. The entire conversion happens locally in your browser using the FileReader API. Your file never leaves your machine — there's no server, no API call, no tracking.
What is the difference between Base64 and Data URI?
Base64 is the encoding itself (defined in RFC 4648). A Data URI wraps the Base64 string with a MIME type prefix like data:image/png;base64, so browsers know how to interpret it. Toggle the prefix on or off depending on your use case.
Why would I embed a file as Base64 instead of linking to it?
Embedding small files (icons, fonts, tiny images) as Base64 reduces HTTP requests, which can speed up page load. It's also useful in email templates and single-file HTML exports where external references aren't practical.
Does Base64 increase file size?
Yes — Base64 encoding increases the data size by roughly 33%. That's why it's best for small files. For large assets, a direct file reference is more efficient.