<link rel="stylesheet" type="text/css" href="/mirawhite.css">

Image to Base64: get a data URI for HTML, CSS or Markdown

Drop an image to get its Base64 version, ready to paste into an <img> tag, a stylesheet or a README, for free. Already have a data URI? Paste it to preview the image and save it as a file.

Free, no sign-up, no limit Runs in your browser: your text and files are never sent or saved.

Image to Base64

Everything happens in your browser: the image is never uploaded.

Drop an image here (PNG, JPEG, GIF, WebP, SVG…)

How to use it

  1. Drop an image (PNG, JPEG, GIF, WebP, SVG, ICO…) or choose it from your device.
  2. Pick the output: data URI, raw Base64, <img> tag, CSS background or Markdown, then copy it.
  3. To go the other way, switch to “Base64 → image”, paste the data URI or the Base64 text, check the preview and download the file.

Example

Input

<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><circle cx="8" cy="8" r="7" fill="#2a9d8f"/></svg>

Output

data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiI+PGNpcmNsZSBjeD0iOCIgY3k9IjgiIHI9IjciIGZpbGw9IiMyYTlkOGYiLz48L3N2Zz4=

Good to know

  • Base64 makes a file about a third bigger, and an inline image cannot be cached separately: keep it for icons and small images. For an SVG, the URL-encoded option is usually shorter.
  • When decoding, the file type comes from the bytes themselves (PNG, JPEG, GIF, WebP, SVG, BMP, ICO, AVIF), not from the label in the data URI.
  • Images up to 20 MB are accepted.

Frequently asked questions

How do I convert an image to Base64?

Drop the image (PNG, JPEG, GIF, WebP, SVG, ICO…) on this page: its Base64 version appears at once. Choose the output, data URI, Base64 only, HTML <img> tag, CSS background or Markdown, and copy it.

How do I use a Base64 image in HTML?

Put the data URI in the src attribute: <img src="data:image/png;base64,iVBOR…" alt="…">. Choose the “HTML <img> tag” output to get the tag ready, or “CSS background” for background-image: url(data:…) in a stylesheet.

How do I convert an image to Base64 in JavaScript or Python?

In the browser, FileReader.readAsDataURL(file) returns the data URI. In Python, base64.b64encode(open("logo.png", "rb").read()).decode() gives the Base64 text, to which you add the data:image/png;base64, prefix yourself.

How do I decode Base64 back to an image?

Switch to “Base64 → image” and paste the data URI or the bare Base64 text; spaces and line breaks are ignored. The real file type is read from the bytes (PNG, JPEG, GIF, WebP, SVG, BMP, ICO, AVIF), then you preview and download it.

Should I embed images as Base64?

Only small ones: Base64 is about a third bigger than the file, and an inline image cannot be cached separately. It suits icons, tiny logos and emails; the tool warns you above 100 KB of Base64, where a regular image file is usually better.

Is there a size limit?

Images up to 20 MB are accepted. Very long results are shortened on screen to keep the page responsive, but copying and downloading always give the full Base64 text. Nothing is uploaded: the encoding runs in your browser.

← Back to all tools