Skip to content
DoItJag

Image to Base64

Turn a small picture such as an icon, logo or email graphic into Base64 text you can paste straight into HTML, CSS, JSON or Markdown, so it travels inside the code without a separate image file.

or drop a file here · PNG, JPG, GIF, WebP, AVIF, SVG, BMP · up to 20 MB

Processed on your device. Your files are not uploaded.

About the Image to Base64 Converter

Base64 is a way of writing binary data, such as the bytes of a picture, using only 64 safe text characters. Wrapped in a data URI, it lets an image live directly inside a web page, a stylesheet, a JSON payload or a Markdown note, with no separate file to host or link.

What you get

After choosing an image you can switch between five ready-made forms:

  • Data URI: data:image/png;base64, followed by the encoded text, usable anywhere a URL to an image is accepted.
  • Base64 only: the raw encoded text, for APIs and configuration files that expect just the payload.
  • HTML: a complete image tag with the data URI as its source and the file name as alternative text, which you should edit to describe the picture.
  • CSS: a background-image declaration.
  • Markdown: image syntax for README files and notes.

The preview at the top is drawn from the generated data URI, so if it shows correctly, the text is correct.

When embedding makes sense

Inline images save a network request, which helps for tiny icons, loading spinners, single-file HTML reports and email signatures in some programs. For anything larger they hurt: the text is about 33 percent bigger than the file, it cannot be cached separately, and it bloats every page that includes it. A useful rule is to embed only images below a few kilobytes. The page warns you when a file is over 100 KB.

Formats

PNG, JPG, GIF, WebP, AVIF, SVG and BMP files up to 20 MB are accepted. The MIME type in the data URI comes from the file’s actual content, not its extension, so a PNG renamed to .jpg is still labelled correctly.

Copying very long results

For big files the text box shows only the beginning, so the page stays responsive. The Copy and Download buttons always use the full text. Encoding happens on your own device; the picture is not uploaded.

How to use Image to Base64

  1. Choose an image (PNG, JPG, GIF, WebP, AVIF, SVG or BMP, up to 20 MB).
  2. Pick the form you need: data URI, plain Base64, HTML, CSS or Markdown.
  3. Check the preview drawn from the result, then copy it or download it as a text file.

Privacy: how it works

Your files are processed on your own device by your browser. They are not uploaded to any server.

Frequently asked questions

Why is the Base64 bigger than my image?

Base64 writes every 3 bytes as 4 letters, so the text is about a third larger than the file. That is why it suits small images best.

Is the image changed or compressed?

No. The exact bytes of your file are encoded, so decoding the text gives back an identical file.

Do data URIs work in emails?

Not reliably: several email programs do not show data URI images, so test before sending. In web pages, CSS and SVG files they work in every current browser.