Image to Base64 Converter

Convert an image to Base64 and get a data URI, an HTML <img> tag or CSS code — or turn Base64 back into an image. Free, no upload.

Updated October 9, 2026 By

Runs in your browser Free · No sign-up

Loading tool…

How to use the Image to Base64 Converter

  1. Drop an image (JPG, PNG, WebP, GIF, SVG) into the box.
  2. Choose the output: data URI, plain Base64, HTML <img>, CSS background or Markdown.
  3. Copy the code — or paste Base64 below to preview and download it as an image.

About this tool

Embedding small icons and logos directly in HTML, CSS or JSON saves an extra request. Drop an image to get its Base64 code in the format you need, or paste Base64 data to see and download the image it contains.

  • Private: your data is processed on your device and never uploaded.
  • Free with no account, limits or watermarks.
  • Fast: results appear instantly, even offline once the page has loaded.

What the Image to Base64 Converter does

This converter turns an image into Base64 text and gives you the code in the format you need: a complete data URI (data:image/png;base64,…), the plain Base64 string, a ready-made HTML <img> tag, a CSS background-image rule or Markdown. It works with JPG, PNG, WebP, GIF, BMP and SVG files, and shows the original and encoded size so you can see what embedding will cost.

It also works the other way round. Paste Base64 data or a data URI — for example from a JSON response, an email source or a stylesheet — and the tool shows the image it contains, detects its type and lets you download it as a normal file.

Everything runs locally in your browser. Neither your images nor your Base64 data are sent to a server.

When to use it

  • Small icons in CSS and HTML

    Embed tiny icons, loading spinners or logos directly in a stylesheet or page to save an HTTP request.

  • Email signatures and newsletters

    Some email tools need images embedded as data URIs instead of linked files.

  • APIs and JSON

    Many APIs send and receive images as Base64 strings. Create test data or check what an API returned.

  • Single-file documents

    Build self-contained HTML reports, demos or offline pages that include their images.

Tips for the best results

  • Use Base64 only for small images. Above roughly 10 KB, a normal image file is usually faster because browsers can cache it separately.
  • Compress the image before converting — every saved kilobyte also saves 1.33 KB of Base64 text.
  • SVG icons can often be embedded even more compactly as URL-encoded SVG, but Base64 works everywhere.
  • If decoding fails, make sure you copied the complete string, including the end, and nothing else.

How the Image to Base64 Converter works

The image file is read with the browser’s FileReader API, which produces a data URI: the MIME type of the file followed by its bytes encoded in Base64. The other formats are built from that string.

For decoding, the tool removes a data-URI prefix if present, cleans whitespace, accepts URL-safe Base64 and adds missing padding. It then checks the first bytes (the “magic number”) to recognize PNG, JPEG, GIF, WebP, BMP or SVG, so it can show and save the image with the correct type even when no MIME type was given.

Base64 represents every 3 bytes with 4 text characters, which is why encoded images are about a third larger than the original file.

Frequently asked questions

When should I use Base64 images?

For small images such as icons, logos or email signatures under about 10 KB. Larger images load faster as normal files that browsers can cache.

Why is the Base64 code larger than the image?

Base64 needs 4 characters for every 3 bytes, so the encoded text is about 33% larger than the original file.

What is a data URI?

A data URI puts a file directly into a link: “data:”, the file type, “;base64,” and the encoded content. Browsers treat it like an image URL.

Is there a size limit?

Images up to 10 MB can be converted here, but such large Base64 strings are rarely practical in code.