← All tools
// Encoding

File to Base64 Converter online

Convert any file to Base64 and generate a Data URI — runs entirely in your browser

File to Base64 Converter logo
by
CHUNKY
MUNSTER
📂
Drop any file here or click to browse
Images, PDFs, fonts, audio, video, any file type

Why is the Base64 output larger than the original file?

Base64 encoding increases data size by approximately 33%. Every 3 bytes of binary data become 4 Base64 characters. This overhead is the trade-off for making binary data safe to transmit in text-only formats.

Can I use the Base64 output directly in HTML?

Yes — paste the full data URI output into the src attribute of an img tag or the url() value in CSS. For example: <img src="data:image/png;base64,iVBOR...">

// Output
Drop or select a file above...

How to Use file-to-base64

  1. Drag and drop a file into the upload area, or click to browse.
  2. The file is read by your browser's FileReader API — nothing is uploaded to any server.
  3. Copy the Base64 string or the complete data URI (data:[type];base64,...).
  4. Use the data URI directly in HTML img src, CSS background-image, or JSON payloads.

Encoding a file to Base64 converts its binary bytes to a string of printable ASCII characters that can be safely embedded in text contexts: HTML data URIs, JSON API payloads, CSS background images, email MIME attachments, and configuration files. This tool reads any file locally in your browser and produces the Base64 string or data URI with no upload required.

Data URIs: Embedding Files in HTML

A data URI has the form data:[mediatype];[encoding],[data]. For a PNG image encoded in Base64: data:image/png;base64,iVBORw0KGgo.... This string can be used directly as an img src, a CSS background-image value, or an href on an anchor tag for a download link. Data URIs are most useful for small files (icons, fonts) — large files produce long strings and slow page parsing.

Frequently Asked Questions

What types of files can I encode to Base64?

Any file. The tool reads raw bytes regardless of format. Images, PDFs, ZIP archives, fonts, audio files, and even binary executables all produce valid Base64 output.

Why is my Base64 string so long?

Base64 expands binary data by approximately 33% — every 3 bytes become 4 characters. A 100 KB image produces about 133,000 Base64 characters. Data URIs over ~5–10 KB can noticeably affect page load performance.

How do I use a Base64 image in CSS?

Use the data URI directly in the CSS: background-image: url("data:image/png;base64,...");. This embeds the image directly in the stylesheet, saving an HTTP request — useful for small repeating patterns and icons.

Can I decode a Base64 string back to a file?

Yes — use the Base64 Encoder tool in Decode mode, paste the Base64 string, and download the resulting binary. The data URI prefix is stripped automatically before decoding.

See also Base64 Encoder, the ASCII85 encoder, and the HTML Formatter.