Image to Base64 Converter

Convert any image to Base64 encoding instantly. Upload your image and get the Base64 string, data URL, CSS background-image value, or HTML img tag ready to copy and paste. Also includes a Base64 decoder — paste any Base64 string to preview and download the image.

Click to upload image

Any image format • Converted instantly in browser

Decode Base64 to Image

What is Base64 Image Encoding?

Base64 is an encoding scheme that converts binary data into a string of ASCII text characters. For images, this means the entire image file (JPG, PNG, GIF, etc.) can be represented as a single long text string. This string can be embedded directly in HTML, CSS, JavaScript, or JSON without needing a separate image URL or file.

Base64 Output Formats

FormatExampleUse case
Raw Base64iVBORw0KGgo...When you need just the encoded data
Data URLdata:image/png;base64,...HTML src attribute, JS
CSS Backgroundurl("data:...")CSS background-image property
HTML img tag<img src="data:..." />Paste directly into HTML

When to Use Base64 Images

  • HTML emails: Many email clients block external image URLs. Embedding images as Base64 ensures they always display.
  • CSS sprites and icons: Embed small icons directly in your stylesheet to avoid HTTP requests.
  • Single-file HTML: Create self-contained HTML files where all assets are embedded.
  • API responses: Return images inline in JSON without hosting them separately.

The 33% Size Overhead

Base64 encoding uses 4 ASCII characters to represent every 3 bytes of binary data. This means a 100 KB image becomes approximately 133 KB as a Base64 string. For production websites, it's generally better to load images as separate files — but for small icons (under 10 KB) and email images, the convenience of Base64 outweighs the size cost.

Frequently Asked Questions

What is Base64 encoding for images?

Base64 is a way to represent binary data (like an image file) as a text string using only ASCII characters. This lets you embed images directly in HTML, CSS, or JSON without needing a separate image file.

When should I use Base64 images?

Base64 images are useful for small images like icons or logos in CSS or HTML emails, embedding images in JSON API responses, avoiding extra HTTP requests for critical small assets, and storing images in databases as text.

Why is the Base64 output larger than the original image?

Base64 encoding adds approximately 33% size overhead compared to the original binary file. This is an inherent property of the Base64 algorithm — every 3 bytes of binary data is encoded as 4 ASCII characters.

What is the difference between Raw Base64 and Data URL?

Raw Base64 is just the encoded string with no prefix. A Data URL includes the MIME type prefix: 'data:image/png;base64,' followed by the Base64 string. Data URLs can be used directly as image src attributes in HTML.

How do I use Base64 as a CSS background image?

Select the 'CSS Background' format option. The output will be formatted as url("data:image/png;base64,...") which you can paste directly into a CSS background-image property.

Related Image Tools