Image to Base64

Convert a JPG, PNG, WebP, GIF or BMP image to a Base64 data URI, raw Base64, an HTML img tag or a CSS background, with size and overhead shown.

Drop an image here or click to browseJPG, PNG, WebP, GIF or BMP

About Image to Base64

Image to Base64 turns a picture into text you can paste straight into HTML, CSS, JSON or an email template. Pick a JPG, PNG, WebP, GIF or BMP file and copy the result in the format you need.

Your files stay on your device

The image is read in your browser; nothing is uploaded. Remember the Base64 text contains the whole picture, so share it as carefully as the image itself.

Four ready-to-paste formats

A data URI for img src or CSS url(), raw Base64 for APIs and JSON, a complete HTML img tag, and a CSS background rule.

When to use it

Inline small icons to save a web request, build single-file HTML pages or email templates, or put test images into JSON fixtures.

When not to

Base64 text is about a third bigger than the file, and it cannot be cached separately. A 30 KB image becomes about 41 KB of text, so keep large pictures as normal files. Shrink the image first with the Image Compressor for shorter text.

Going the other way

To turn Base64 back into a picture, use the Base64 Image Viewer.

How to use Image to Base64

  1. Drop an image on the page or click to choose it.
  2. Check the dimensions, size and type that the tool shows.
  3. Choose the format: Data URI, Raw Base64, HTML <img> or CSS background.
  4. Press Copy, or Download .txt to save the text.

Related guide: Base64 Explained: What It Is and When to Use It

Help & FAQ

What does Image to Base64 do?

It encodes an image as Base64 text and gives it as a data URI, raw Base64, an HTML img tag or a CSS background snippet.

Which image types can we use?

JPG, PNG, WebP, GIF and BMP.

What is a data URI?

It is a link that holds the file itself, such as data:image/png;base64, followed by the encoded data. A browser can display it without a separate request.

Why is the Base64 text larger than the image?

Every 3 bytes become 4 characters, so the text is about one third larger, slightly more with padding on small files. The tool shows the overhead.

When should we embed an image as Base64?

For small icons or single-file pages and emails. For large images a normal file is better because it can be cached and compressed.

What is the difference between Data URI and Raw Base64?

The data URI includes the data:image/...;base64, prefix. Raw Base64 is only the encoded data.

Can we use the result in CSS?

Yes. The CSS background option gives a rule that uses the data URI in url().

Does the tool compress or resize the image?

No. It encodes the file as it is. Shrink the image first if you want shorter text.

Is an animated GIF changed?

No, the file bytes are encoded as they are, but the text can be very long.

Is our image uploaded?

No. It is read in your browser. In a test, only the site's small analytics calls were made.

How can we turn Base64 back into an image?

Use the Base64 Image Viewer. Paste the text there to see and download the image.

Why does our editor lag with the result?

A big image gives a very long line of text. Use a smaller image or keep the file separate.

More in Image Tools

See all 47 in Image Tools