File to Base64 Converter (with data URI support, both directions)
Convert any file (image, PDF, and more) to a Base64 string or data URI, or decode a Base64 string / data URI back into a downloadable file. Everything runs in your browser — files are never sent to a server.
Tips
- The File → Base64 mode accepts any file type — images, PDFs, audio, and more — and lets you copy both the data URI form and the plain Base64 string.
- In Base64 → File mode, paste a full data URI starting with
data:and the MIME type is detected automatically. For a plain Base64 string, select the MIME type manually. - Every conversion runs entirely in your browser's JavaScript — the file content or Base64 string is never sent to a server, which makes this safe for sensitive files.
- To embed a small icon directly in CSS or HTML, paste the data URI output straight into
background-image: url(...)or an<img>tag'ssrc. - Base64 encoding makes the output about 33% larger than the original file, so converting very large files (tens of megabytes or more) can make your browser feel sluggish.
FAQ
data:image/png;base64,iVBOR.... Because it also carries the MIME type, you can drop it straight into an <img> tag's src attribute or a CSS background-image to display the image.data:, a MIME type dropdown appears — pick the original file format (image, PDF, text, and so on) manually before downloading.
Side Note — Why Base64 Makes Files 33% Larger
Base64 encoding exists because many transport channels — email, JSON, URLs — can only safely carry printable ASCII text. Sending arbitrary binary data (like an image or an executable) as-is risks corruption from stray control characters, so Base64 was devised to represent any binary payload using just 64 printable characters: A–Z, a–z, 0–9, +, and /.
Base64 slices 3 bytes (24 bits) of binary data into four 6-bit chunks and maps each chunk to one Base64 character. Repacking 8-bit binary into 6-bit characters means the encoded output ends up roughly 4/3 the size of the original — about 33% larger. That size increase is the price paid for text-safe transport.
This same trick is put to good use in data URIs, which embed small images directly in HTML or CSS as data:image/png;base64,.... Doing so avoids an extra HTTP request for tiny assets like icons, which can speed up page loads. But the roughly 33% size overhead and the loss of browser caching make it a poor fit for large image files.