Image to Base64

Convert a PNG, JPG, SVG, WebP or GIF image to Base64 or a data URL for HTML, CSS or JSON. Files up to 20 MB. Free, converted in your browser, not uploaded.

Runs in your browser. Your files are never uploaded. How it works

Image to Base64 turns an image into a Base64 string or a ready-to-paste data URL, so you can put it straight into HTML, CSS, JSON or an email template without a separate file. It works with PNG, JPG, GIF, WebP, SVG and any other file up to 20 MB. The image is encoded in your browser and never uploaded.

How to convert an image

  1. Choose or drop an image under File or image to Base64.
  2. Leave As a data URL ticked for HTML and CSS, or untick it for raw Base64, as many APIs expect.
  3. Click Copy, or Download to save the text as a file.

Using the result

In an HTML image tag:

<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA..." alt="Company logo" width="120" height="40">

As a CSS background:

.logo { background: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA...") no-repeat; }

In JSON, for an API that accepts images:

{ "filename": "logo.png", "content": "iVBORw0KGgoAAAANSUhEUgAA..." }

For JSON and most APIs, use plain Base64 without the data: prefix.

When a data URL makes sense

Good fit Better as a normal file
Icons and logos under a few KB Photos and large images
Email templates that must show images Images used on many pages
Single-file HTML demos and reports Anything you update often
Small images in JSON or a database Images that should be cached

A data URL saves one request but makes the HTML or CSS bigger, and the browser cannot cache the image on its own. For anything larger than a small icon, a separate image file is usually faster.

Make it smaller first

Every byte of the image becomes about 1.33 bytes of text. Shrink it before you convert:

Turning it back

To get the image back from a Base64 string or a data URL, see Base64 Decode.

Frequently asked questions

How do I convert an image to Base64?

Choose or drop an image. It is converted straight away. Leave As a data URL ticked to get a string that starts with data:image/...;base64, ready for an img tag or CSS, or untick it for plain Base64. Then copy or download the result.

How much bigger does the image get?

Base64 is about a third larger than the original file: a 30 KB image becomes about 40 KB of text. That is why data URLs suit small images like icons and logos, not large photos.

Can I convert other files, such as fonts or PDFs?

Yes. Any file up to 20 MB works, including fonts for @font-face, PDFs and audio. The data URL uses the file's own type.

Is my image uploaded?

No. The image is read and encoded in your browser, on your device. It is never sent to a server.

More ways to use Base64 Encode and Decode

Related tools