How to convert an image to Base64
- 1Drop your images into the box above, or click Choose images.
- 2Choose a data URI, a CSS background or an HTML img tag.
- 3Click the copy button next to each image.
What is a Base64 image?
Base64 turns an image file into plain text. Put that text in a data URI, like data:image/png;base64,iVBOR..., and you can use it anywhere an image address goes, with no separate file to host.
When to use it
- Small icons and logos in HTML emails, where linked images are often blocked
- Tiny images in CSS, to save an extra request
- Images inside JSON, config files or single-file HTML pages
When not to use it
Base64 text is about a third larger than the original file, and browsers can't cache it separately from your page. For photos and anything over about 10 KB, a normal image file is usually faster. The tool warns you when an image is large.
The output options
- Data URI: the raw
data:address, for anywhere that takes a URL. - CSS: a ready-made
background-imagerule. - HTML: a complete
<img>tag with width and height filled in.