Free · Client-Side · Zero Uploads

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

PNGJPEGSVG PDFMP3MP4 WOFF2ZIPAny File
Reading file…
📄

File preview
Raw Base64 0 chars
Data URI
Size:
All
File Types Supported
5
Snippet Types
0ms
Server Latency
100%
Private & Secure

Encode Any File in Three Steps

No sign-up, no server uploads. Drop, encode, and copy in seconds right in your browser.

1

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.

2

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.

3

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 TypeMIME TypeExtension(s)Data URI SupportPrimary Use Case
📷PNG Imageimage/png.pngUniversalUI icons, logos, screenshots in HTML & CSS
🖼JPEG Imageimage/jpeg.jpg, .jpegUniversalPhotos, email thumbnails, og:image embedding
🎨SVG Imageimage/svg+xml.svgUniversalScalable icons, CSS backgrounds, inline HTML
📄PDF Documentapplication/pdf.pdfChrome, Firefox, EdgeEmbed PDFs via <embed> or <object>
🎵MP3 Audioaudio/mpeg.mp3UniversalNotification sounds, UI audio, JS Audio()
🎬MP4 Videovideo/mp4.mp4Chrome, Firefox, EdgeShort animations, embedded video players
🔞WOFF2 Fontfont/woff2.woff2UniversalSelf-contained CSS @font-face, no CDN
📦ZIP Archiveapplication/zip.zipRaw Base64 onlyAPI payloads, email attachments
🌐WebP Imageimage/webp.webpChrome, Firefox, EdgeModern 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.

01

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.

02

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.

03

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.

04

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.

05

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.

06

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.

// Any file → Base64 (browser-native)
 
const reader = new FileReader();
 
reader.onload = (e) => {
  // Full data URI:
  const dataUri = e.target.result;
  // "data:image/png;base64,iVBOR…"
 
  // Raw Base64 only:
  const b64 =
    dataUri.split(',')[1];
 
  // Use as <img> src:
  img.src = dataUri;
};
 
reader.readAsDataURL(file);

Frequently Asked Questions

Everything you need to know about encoding files to Base64.

Base64 encodes every 3 bytes as 4 ASCII characters, producing output approximately 33% larger than the original binary. A 1 MB PNG becomes roughly 1.37 MB of Base64 text. This overhead is unavoidable it is the cost of representing binary data as printable ASCII. For large files, linking to a hosted URL is more bandwidth-efficient than embedding as Base64.
There is no hard limit enforced by the tool. However, 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.
No. The entire encoding process uses the browser's native 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.
Use the data URI as the 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.
Yes. Use an <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.
The Data URI Builder handles two tasks: (1) combining a raw Base64 payload with a MIME type selector to produce a complete 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.
Encode your WOFF2 or TTF font file here, copy the data URI, then use it in a CSS @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.
The Blob + Object URL snippet decodes the Base64 string back to binary bytes, wraps them in a 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.