Drop an image here or
How to use the Image to Base64 Converter
- Drop or select an image.
- Choose the output format, Data URL, raw Base64, CSS background-image snippet, or HTML img tag.
- Click Copy and paste the result wherever you need it.
Output format guide
- Data URL: a self-contained URI (
data:image/png;base64,...) that can be used anywhere a URL is accepted:srcattributes,url()in CSS, fetch calls, and more. - Base64 only: the raw encoded string without the
data:prefix. Use this when you need to pass the image data to an API endpoint or embed it in JSON. - CSS background-image: ready-to-paste CSS rule:
background-image: url("data:image/png;base64,...") - HTML img tag: a complete
<img src="data:...">element you can drop directly into HTML.
When to use Base64 images
Base64-encoded images can be embedded directly in HTML, CSS, JSON, or email templates without a separate HTTP request. This reduces the number of network round-trips, which can speed up rendering for small assets.
However, Base64 increases file size by about 33%. For large images this overhead outweighs the benefit of avoiding an extra request. The general rule: inline images smaller than ~5 KB; use separate files for anything larger.