Skip to main content

Image to Base64

Convert any image to a Base64 encoded string for embedding in code.

Built and tested by Muhammad Irfan Liaqat · Updated

🔗

Drop an image or click to upload

Image to Base64: key facts

  • Converts an image into a Base64 data URI that starts with data:image/…;base64,
  • Copy it as a raw string, an HTML <img> tag or a CSS background-image value
  • Shows the original file size; the Base64 text is about a third larger
  • One image at a time, read in the browser

When to embed an image as Base64

Upload an image to convert it into a Base64 data URI that you can paste straight into code. Copy the Base64 string, a complete HTML <img> tag or a CSS background-image value, and see the original file size next to the encoded size.

Embedding an image as Base64 saves a separate network request, which helps for small icons, email signatures and single-file HTML pages. The cost is size and caching: Base64 is about 33% larger than the original file, it cannot be cached separately from the page, and it makes HTML and CSS harder to read. As a rule of thumb, embed images under about 10 KB and serve larger ones as normal files. The image is read in your browser and never uploaded.

How to convert an image to Base64

  1. 1Drop in an image or click to choose one
  2. 2Check the Base64 output and the size comparison
  3. 3Click Copy Base64, Copy <img> Tag or Copy CSS
  4. 4Paste the code into your HTML, CSS or JavaScript

Frequently Asked Questions

Why convert an image to Base64?
So it can be embedded inside an HTML, CSS or JSON file instead of loaded as a separate file. This is useful for small icons, email templates and self-contained pages.
How much larger does Base64 make an image?
About 33%, because every 3 bytes are written as 4 characters. A 9 KB icon becomes roughly 12 KB of text.
Should I use Base64 images on a website?
Only for very small images. Larger embedded images increase the page size, cannot be cached on their own and delay the rest of the page, so serve them as normal image files.
Are my images uploaded?
No. The conversion happens in your browser.
How do I convert Base64 back to an image?
Paste the full data URI, starting with data:image/, into your browser's address bar and press Enter. The image opens and you can save it.
Does the output include the data:image prefix?
Yes. You get a complete data URI with the MIME type, such as data:image/png;base64,iVBOR…, which works directly in an img src or CSS url().
Is there a size limit?
There is no set limit, but large images make very long strings that slow down HTML and CSS files. Base64 is best for small icons and images under a few kilobytes.

Related Tools

Guides