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

  1. Add an image.
  2. Choose Output: data URI, Base64 text only, a ready-made <img> tag, or a CSS background-image rule.
  3. 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.

All guides

↑ ↓ navigateEnter openEsc close