Photos & videos are never uploaded or stored.

Why?
BROWSER CAMERA

Image to Base64 Converter

Encode any image as Base64 and get ready-to-paste data URI, HTML, CSS and Markdown code, with an option to shrink the image first so the text stays short.

Drop an image here, or click to choose

Any image: PNG, JPG, WebP, SVG, GIF, ICO, AVIF … Encoded on your device, never uploaded.

Settings

Encode

Format
Size

Original encodes the file byte for byte. Another format or a smaller size re-saves it first, often making the text much shorter.

SVG

SVG data URI

SVG is text, so a URL-encoded data URI is usually shorter than Base64 and still works in HTML and CSS.

Updated

Convert an image to Base64

Drop an image above. You immediately get:

  • Data URI: data:image/png;base64,iVBORw0…, usable anywhere a URL is
  • Base64: just the encoded text, for APIs and JSON
  • HTML: <img src="data:…" alt="…" width="…" height="…">
  • CSS: background-image: url("data:…");
  • Markdown: ![alt](data:…)

Each has a Copy button. Very long results show a shortened preview, but Copy always copies the complete text, and you can also download it as a .txt file.

What Base64 encoding is

Base64 turns binary data into text using 64 safe characters. Every 3 bytes become 4 characters, so the encoded text is about 33 % larger than the file. In return it can travel anywhere only text is allowed: inside HTML and CSS files, JSON, XML, email bodies and environment variables.

A data URI adds the type in front: data:[MIME type];base64,[data]. Browsers treat it like a link to a file, except the file is embedded in the page itself.

Make the text shorter first

Every byte counts when an image is embedded in code. The settings can re-save the image before encoding:

  • Format: Original (byte-for-byte), or WebP (usually the shortest for photos and graphics), PNG or JPG.
  • Size: Original, or scale down so the longest side is 512, 256 or 64 pixels: perfect for icons and thumbnails.

The size before and after encoding is shown, with the +33 % overhead, so you can see the effect.

When to use Base64 images, and when not

Good uses:

  • Small icons, logos and UI graphics (under ~10 KB)
  • HTML emails, where linked images are often blocked
  • Single-file HTML pages, offline documents, bookmarklets
  • JSON APIs, config files and databases that only store text
  • CSS sprites or placeholders that must render instantly

Avoid for:

  • Photos and large images. They inflate HTML and CSS, can't be cached separately and delay rendering. Serve them as normal files (as WebP or AVIF; the Image Compressor helps).

SVG: URL-encoding beats Base64

SVG is already text, so Base64 just makes it a third longer. A URL-encoded data URI (data:image/svg+xml,%3Csvg…) only escapes the characters that need it and is usually shorter. Choose it under SVG data URI.

Private by design

The image is encoded on your device by your browser. Nothing is uploaded, which matters for unpublished designs and internal assets.

Frequently asked questions

What is a Base64 image?

It is the image's bytes written as plain text using 64 characters (A–Z, a–z, 0–9, + and /). As a data URI (data:image/png;base64,…) it can be put straight into HTML, CSS, JSON or email without a separate file.

Is the image changed when I encode it?

Not with Format and Size set to Original: the file is encoded byte for byte. Choosing WebP, PNG, JPG or a smaller size re-saves it first to make the text shorter.

Why is the Base64 text bigger than the image?

Base64 uses 4 characters for every 3 bytes, so it is about 33 % larger than the file, plus the data:…;base64, prefix.

When should I use Base64 images?

For small images (icons, logos, tiny backgrounds, roughly under 10 KB) where saving an extra request helps, in HTML emails, and in JSON or APIs that only carry text. Larger images are better as normal files, which browsers can cache.

How do I use it in CSS?

Copy the CSS snippet: background-image: url("data:image/png;base64,…"); and paste it into your stylesheet rule.

How do I use it in HTML?

Copy the HTML snippet, an <img> tag with the data URI as src, alt text from the file name, and the width and height.

What is the best way to encode SVG?

SVG is text, so a URL-encoded data URI (data:image/svg+xml,…) is usually shorter than Base64 and works in HTML and CSS. Choose URL-encoded in the SVG settings.

Is my image uploaded?

No. It is read and encoded by your browser on your device.

Which formats are supported?

Any: PNG, JPG, WebP, AVIF, GIF (including animated, as the original file), SVG, ICO, BMP, HEIC and more. The MIME type in the data URI is taken from the file's actual contents.

How do I turn Base64 back into an image?

Use Base64 to Image: paste the text and download the image.

Related tools