Image to Base64 Converter (and Base64 to Image)

Turn a PNG, JPEG, SVG, WebP or GIF into a Base64 data URI with copy-ready CSS and HTML — or paste a Base64 string to preview and download the image.

Runs in your browser

Choose an image or drag & drop it here

PNG, JPEG, SVG, WebP, GIF, AVIF, ICO · or paste with Ctrl+V

Your data never leaves your computer. All processing happens 100% locally in your browser.

How to use the Image to Base64

  1. In Image → Base64, drop or choose an image. It is read locally — nothing is uploaded.
  2. Copy the data URI, or the ready-made CSS background or <img> snippet. Untick “data: prefix” if you need the raw Base64 only.
  3. For SVGs, switch to URL-encoded — it is usually shorter than Base64.
  4. To go the other way, open Base64 → Image, paste a string and download the decoded file.

What is an image to Base64 converter?

Base64 is a way of writing binary data using only 64 safe text characters (A–Z, a–z, 0–9, + and /). Converting an image to Base64 lets you embed it directly inside HTML, CSS, JSON or an email template as a data URI instead of linking to a separate file:

data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA…

The part before the comma declares the MIME type; the rest is the encoded file. Browsers treat it exactly like an image URL, so it works in <img src>, CSS background-image, <link rel="icon"> and canvas code.

The 33% size overhead

Base64 stores every 3 bytes of the file as 4 characters, so the encoded string is about 33% larger than the original (plus the short data: prefix). Gzip or Brotli on your server recovers part of that, but the bigger costs are structural: an inlined image is downloaded again with every HTML or CSS file that contains it, cannot be cached on its own, and makes your stylesheet — which blocks rendering — heavier.

When to inline images (and when not to)

  • Good fit: small icons, loaders and UI sprites under a few KB, images in HTML email signatures where external images are blocked, single-file HTML reports, and test fixtures in code.
  • Bad fit: photos, hero images and anything above roughly 10–20 KB. Serve those as normal files with caching, compression and loading="lazy". Shrink them first with the Image Compressor.

SVG: URL-encoding beats Base64

SVG is already text, so you don’t need Base64 at all. A URL-encoded data URI such as data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg'… only escapes a few characters (<, >, #, %) and is typically 20–30% shorter than the Base64 version — and it stays readable and gzips better. This tool offers both for SVG files. If you work with SVG in CSS a lot, the SVG to CSS tool helps too.

Decoding Base64 back to an image

Paste a full data URI or a bare Base64 string (base64url with - and _ also works). The tool detects the real format from the file’s magic bytes — PNG, JPEG, GIF, WebP, AVIF, SVG, ICO or BMP — shows a preview with dimensions, and lets you download the file with the right extension. For Base64 that isn’t an image, use the general Base64 Encoder/Decoder.

Tools that pair well with the Image to Base64

  • Favicon Generator — Make a complete favicon package from a logo, a letter or an emoji: a multi-size favicon.ico, Apple touch icon, Android/PWA icons, a Webflow webclip, the web manifest and the HTML tags to paste.
  • Image Resizer — Resize a photo to exact pixel dimensions or a percentage, crop it to fill a social-media size, or fit it inside a frame with a background colour — all locally in your browser.
  • OG Image Generator — Create a polished link-preview image for Facebook, LinkedIn, X, Slack and WhatsApp in seconds — pick a template, type your title, add a logo, then download the PNG and matching meta tags.
  • QR Code Generator — Generate a QR code for a link, Wi-Fi login, contact card, email, phone number or SMS.

Frequently asked questions

Why is the Base64 string bigger than my image?
Base64 represents every 3 bytes with 4 text characters, which adds about 33% to the size. That overhead is the price of being able to paste binary data into text formats like HTML, CSS and JSON.
How do I use a Base64 image in CSS?
Put the data URI inside url(): background-image: url("data:image/png;base64,…");. The CSS snippet above is ready to paste — just rename the selector.
Does inlining images as Base64 improve page speed?
Only for very small images, where saving an HTTP request outweighs the extra bytes. With HTTP/2 and HTTP/3 requests are cheap, so inline only tiny icons and keep larger images as cacheable files.
Is it safe to convert private images here?
Yes. The file is read with the FileReader API in your browser and never sent anywhere.
Why does my pasted Base64 show an error?
Common causes are a truncated string (copy it completely), stray characters such as quotes or line numbers, or data that isn’t actually an image. The tool strips whitespace, url() wrappers and quotes automatically.

Related tools