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