Convert Any File to Base64
Drop any file image, PDF, audio, video, font, ZIP, or binary and instantly get a Base64 string, data URI, and ready-to-use HTML & JavaScript snippets. Nothing ever leaves your browser.
Drop any file here or click to browse
Supports images, PDFs, audio, video, fonts, ZIP archives, and any binary file
Encode Any File in Three Steps
No sign-up, no server uploads. Drop, encode, and copy in seconds right in your browser.
Drop or Browse Your File
Drag any file onto the drop zone image, PDF, audio, video, font, ZIP, or any binary. The file is read directly by the browser using FileReader, with no upload to any server.
Instant Base64 Encoding
The browser reads the file bytes and converts them to a Base64 string using FileReader.readAsDataURL(). Both the raw Base64 and the full data:[mime];base64,… URI are displayed immediately.
Copy, Download or Embed
Copy the Base64 string or data URI to clipboard, download as a .txt file, or head to the Snippet tab to generate ready-to-paste HTML and JavaScript code for your project.
Everything You Need to Encode Files
Upload, preview, copy, and generate code snippets all in one private, browser-based tool.
Any File Type
Encode images (PNG, JPEG, GIF, WebP, SVG, AVIF), PDFs, audio, video, web fonts (WOFF2, TTF), ZIP archives, or any binary file. The MIME type is auto-detected and used in the data URI prefix and all snippets.
Image Preview
When an image file is uploaded, a live preview is shown alongside the encoded output so you can verify the correct file was selected before copying the Base64 string.
5 Code Snippets
Generate an HTML <img> tag, an <embed> for PDFs, a JavaScript Blob + Object URL, a fetch() from a data URI, or a CSS background-image all pre-filled with your encoded file.
Data URI Builder & Stripper
Build a complete data URI from raw Base64 and a MIME type selected from an exhaustive list covering images, audio, video, fonts, and binary types or strip any existing data URI back to raw Base64.
Size Overhead Report
After encoding, see the original file size, the Base64 output size, and the exact overhead percentage. Helps you decide whether inline embedding is practical or whether a hosted URL is more bandwidth-efficient.
100% Private
All encoding uses FileReader.readAsDataURL() a native browser API. Your file bytes never leave your device. Safe for contracts, design assets, private keys, and any confidential content.
File Type & MIME Reference
Common file types, their MIME types, data URI browser support, and typical Base64 embedding use cases.
| File Type | MIME Type | Extension(s) | Data URI Support | Primary Use Case | |
|---|---|---|---|---|---|
| 📷 | PNG Image | image/png | .png | Universal | UI icons, logos, screenshots in HTML & CSS |
| 🖼 | JPEG Image | image/jpeg | .jpg, .jpeg | Universal | Photos, email thumbnails, og:image embedding |
| 🎨 | SVG Image | image/svg+xml | .svg | Universal | Scalable icons, CSS backgrounds, inline HTML |
| 📄 | PDF Document | application/pdf | Chrome, Firefox, Edge | Embed PDFs via <embed> or <object> | |
| 🎵 | MP3 Audio | audio/mpeg | .mp3 | Universal | Notification sounds, UI audio, JS Audio() |
| 🎬 | MP4 Video | video/mp4 | .mp4 | Chrome, Firefox, Edge | Short animations, embedded video players |
| 🔞 | WOFF2 Font | font/woff2 | .woff2 | Universal | Self-contained CSS @font-face, no CDN |
| 📦 | ZIP Archive | application/zip | .zip | Raw Base64 only | API payloads, email attachments |
| 🌐 | WebP Image | image/webp | .webp | Chrome, Firefox, Edge | Modern web images with smaller file sizes |
When You Need a File as Base64
Encoding files as Base64 solves real problems across web development, APIs, email, and application design.
Inline Images in HTML & CSS
Small UI images icons, logos, spinners, decorative shapes can be embedded directly in HTML or CSS as data:image/png;base64,…. No external file requests, no broken image paths after deployment, and no CDN dependency. Ideal for email templates and single-file components.
Self-Contained Web Font Loading
Encode WOFF2 or TTF fonts as Base64 and embed them directly in a CSS @font-face rule. Eliminates the need for an external font CDN, makes fonts work fully offline, and prevents the flash of unstyled text caused by late-loading external font files.
API Payload Testing
Many APIs accept files as Base64 strings in JSON request bodies document OCR, speech recognition, image analysis, PDF processing. Encode your test file here and paste the output directly into your API request body, Postman collection, or curl command.
Single-File App Asset Bundling
Encode images, sounds, and fonts as Base64 and include them directly in a JavaScript bundle or JSON config. Simplifies deployment of browser extensions, offline-first PWAs, and Electron apps that need assets bundled without extra HTTP requests.
Email Attachment Debugging
MIME email messages Base64-encode all attachments. Paste the raw Base64 payload from a .eml file here to preview the decoded attachment, or encode a local file to manually construct a MIME email attachment for testing email templates.
PDF & Document Embedding
Embed PDFs directly in HTML using <embed src="data:application/pdf;base64,…"> for in-browser viewing without a separate server URL. Useful for report viewers, document portals, and kiosk applications that need self-contained HTML files.
File to Base64 Encoding Explained
All files are binary data sequences of bytes representing pixels, audio samples, document structure, font curves, or compressed archive entries. Base64 encodes this binary data as printable ASCII text by converting every 3 bytes into 4 characters, producing output approximately 33% larger than the original file.
The browser's FileReader.readAsDataURL() API reads the file bytes and returns a complete data URI in the format data:[mime-type];base64,[encoded-data]. The raw Base64 string is the portion after the first comma. The MIME type prefix tells the browser how to interpret the data when it is used as a src or href attribute.
This data URI can be used as the src of an <img>, <audio>, or <video> element, as a CSS url() value, passed to JavaScript APIs, or stored as a string in JSON or a database. No server is ever involved the entire encoding pipeline runs in your browser using native Web APIs.
Frequently Asked Questions
Everything you need to know about encoding files to Base64.
FileReader.readAsDataURL() holds the entire file and the resulting Base64 string in browser memory simultaneously. For files over 2025 MB the browser tab may slow down temporarily. For typical use cases icons, thumbnails, small PDFs, web fonts, notification sounds file sizes are comfortably within limits.FileReader API. The file bytes are read directly from your local disk into browser memory no network request is made. The tool works fully offline after the initial page load, making it safe for contracts, design files, private media, and any confidential content.src attribute of an <img> element: <img src="data:image/png;base64,iVBOR…">. In CSS, use it as a url() value: background-image: url('data:image/png;base64,…'). The HTML / JS Snippet tab generates these code blocks pre-filled with your encoded file.<embed> or <object> element with the data URI as its src: <embed src="data:application/pdf;base64,JVBERi…" type="application/pdf">. This works in Chrome, Firefox, and Edge. Safari has limited support for Base64 PDFs in embed elements. For large PDFs, a hosted URL with a viewer library is generally more practical.data:[mime];base64,… URI useful when you already have raw Base64 from an API response or database field but need to wrap it for use in HTML or CSS; and (2) stripping an existing data URI back to raw Base64 useful when an API expects the Base64 payload without the data URI prefix.@font-face rule: @font-face { font-family: 'MyFont'; src: url('data:font/woff2;base64,d09GRg…') format('woff2'); }. This embeds the font directly in your stylesheet, eliminating external font requests and preventing FOUT on first render.Blob, and creates an object URL with URL.createObjectURL(). This is more memory-efficient for large files than using the raw data URI directly as a src, because the browser can stream from the Blob rather than holding the full Base64 string in the DOM.