Free tool • Runs in your browser
Image to Base64
Convert an image to a Base64 string, data URI, HTML tag or CSS snippet.
Quick answer
Base64 turns an image into text that can sit directly in HTML, CSS or JSON. It makes the data about 33% larger, so it is best for small icons rather than photos.
How to use it
- Add an image.
- Choose raw Base64, data URI, HTML or CSS output.
- Copy the result.
Example
icon.png
data:image/png;base64,iVBORw0KGgo...
Common errors and how to fix them
- The page became slow
- Large images make very long strings. Use a normal image file for anything over a few KB.
Frequently asked questions
How do I convert an image to Base64?
Add your image and copy the data URI, raw Base64, HTML or CSS output.
Why would I convert an image to Base64?
It lets you embed an image directly in HTML, CSS or JSON, which is useful for small icons and self-contained files.
How do I use a Base64 image in HTML?
Choose HTML output and paste the tag. It uses the data URI as the image's src.
How do I use a Base64 image in CSS?
Choose CSS output, and paste the background-image line into your rule.
How do I convert an image to Base64 in JavaScript?
In the browser, use FileReader's readAsDataURL method. It returns a data URI.
How do I convert an image to Base64 in Python?
Read the file in binary mode and pass the bytes to base64.b64encode, then decode the result to text.
Does Base64 make an image larger?
Yes, by about 33%, because it uses 4 text characters for every 3 bytes.
When should I avoid Base64 images?
Avoid it for photos and large images, as long strings add page weight and are not cached separately.
What is a data URI?
It is a string that contains the file's type and data, starting with data:image/png;base64, for example.
Are my images uploaded?
No. Your image is processed in your browser and is not uploaded to Quecko.
More image tools
Need something built for your business?
Quecko designs and builds AI, Web3 and custom software products.