Convert an image to Base64

Embed small images straight into HTML, CSS or JSON. Or paste a Base64 string to turn it back into a file.

Image to Base64 on AllFreeImage, with the picture on the left and the settings on the right

What Base64 is for

It writes a file as plain letters and numbers, so a picture can sit inside HTML, CSS, JSON or an email template without a separate file. The snippets here are ready to paste: a data URL, a CSS background, an HTML image tag with the right width and height, and the bare text.

When it helps and when it hurts

Tiny icons, loading placeholders and single-file pages are good uses, because the browser saves one request. For anything over about 10 KB a normal file is better. Base64 adds a third to the size, cannot be cached separately, and has to be read before the rest of the page can continue.

Turning text back into a picture

Paste a data URL or bare Base64 into the box further up and press Decode. You will see the picture, its size in pixels, and a download button. It is useful for checking what an API or a stylesheet really contains.

How to convert an image to Base64

  1. Drop an image.
  2. Copy the data URL or snippet.
  3. Paste it into your code.

Related tools

Questions

When should I use Base64?

For small icons and placeholders under about 10 KB. Larger images are better as normal files, since Base64 adds a third to the size.

Is Base64 a kind of encryption?

No. Anyone can turn it back, as the decoder on this page shows. Never use it to hide something.

Should I use SVG instead?

For simple icons, yes. An SVG is text already and is usually smaller.

Are my images uploaded?

No. Every tool runs inside this page on your own device. You can switch off your internet after the page loads and most tools keep working.

Is it really free?

Yes. There is no account, no daily limit and no watermark on your results.