Advertisement

Image to Base64 Converter

Convert PNG, JPG, GIF, WebP, AVIF, SVG or ICO images to Base64. Copy a data URI, raw Base64, CSS, HTML img or Markdown snippet — all in your browser.

Any image type works. Files are read locally.

Base64 turns an image file into plain text, so it can sit inside HTML, CSS, JSON, Markdown or an email template as a data URI instead of being loaded as a separate file. Choose any image — PNG, JPG, GIF, WebP, AVIF, SVG, ICO or BMP — and copy the raw Base64, a ready data URI, a CSS background rule, an HTML <img> tag or a Markdown image. The file is read on your device and never uploaded.

How to use this tool

  1. Choose one or more image files.
  2. Pick the output: data URI, raw Base64, CSS, HTML <img>, Markdown, or all of them.
  3. Optionally type alt text for the HTML and Markdown snippets.
  4. Press Copy result, or download the .txt file offered for very large images.

Formula

Base64 length = 4 × ⌈bytes ÷ 3⌉; data URI = data: + MIME type + ;base64, + Base64

Every 3 bytes become 4 characters from the 64-character alphabet of RFC 4648, so the text is about 33% bigger than the file, a little more for tiny files because of the "=" padding. The MIME type is read from the file's first bytes (its magic number) when they are recognised, because file names and reported types are sometimes wrong; otherwise the browser's type or the extension is used.

Example

The 163-byte test SVG (120 × 80 px) becomes 4 × ⌈163 ÷ 3⌉ = 220 Base64 characters, 35% more than the file, starting PHN2ZyB4bWxucz0i. The data URI adds the 26-character prefix data:image/svg+xml;base64, for 246 characters in total, and the HTML snippet gets width="120" height="80" read from the image itself.

Frequently asked questions

When should I inline an image as Base64?

For small images such as icons, tiny logos and placeholders of a few KB, where saving a request matters, or where one self-contained file is needed: offline pages, JSON APIs, single-file HTML reports. For anything large, link to the file instead.

Is Base64 a way to compress or protect an image?

No. It makes the data about a third bigger, and anyone can decode it in a second.

Do data URIs work in HTML emails?

Not reliably. Apple Mail shows them, but Gmail and several Outlook versions block data-URI images, so hosted or attached images are safer for newsletters.

How do I turn Base64 back into an image?

Paste it into the Base64 to File converter and download the file; the type is detected from its bytes.

Sources

Last updated: 2026-10-30

Advertisement