How to convert an image to Base64 (data URI, img tag or CSS)
Embedding an image directly in HTML or CSS saves a request. Image to Base64 generates the code.
Steps
- Add an image.
- Choose Output: data URI, Base64 text only, a ready-made
<img>tag, or a CSSbackground-imagerule. - Copy the code or download the text file.
What to expect
Base64 makes data about a third larger. The tool tells you how big the text is compared to the original image. Use it only for small images such as icons and tiny logos.
Tips
- Compress or shrink first with Compress image so the code is shorter.
- Large images embedded in HTML cannot be cached separately and slow the page; keep them as files.
- Wondering what Base64 is? Read Base64 explained.