Image to Base64

Convert any image to a Base64 string or data URL — instantly, in your browser. Nothing is uploaded.

🖼️
Drop an image here
or click to browse — PNG, JPG, WEBP, GIF, SVG, BMP, ICO…
Preview
Data URL (use directly in HTML/CSS)
Base64 string only
HTML <img> tag
CSS background-image

Paste a Base64 string or full data URL below to preview and download the image.

Decoded image

How to convert an image to Base64

  1. Click the upload area or drag and drop any image — PNG, JPG, WEBP, GIF, SVG, BMP, ICO. The conversion happens instantly the moment the file is selected.
  2. You'll see four outputs: Data URL (use directly in HTML/CSS), Base64 string (the encoded data only), a ready-to-paste <img> tag, and a CSS background-image rule.
  3. Click Copy next to whichever output you need and paste it into your code.
  4. To go the other way, switch to the Decode tab, paste a Base64 string or data URL, and click Decode to preview and download the image.

What is Base64 image encoding?

Base64 encoding converts binary data (like an image file) into a string of 64 printable ASCII characters. This lets you embed an image directly inside HTML, CSS, JSON, or any text-based file — no separate image file or network request needed. The tradeoff is about 33% larger file size compared to the original binary.

A data URL is a Base64 string prefixed with the MIME type: data:image/png;base64,iVBORw0K…. You can use this directly as the src of an <img> tag or in a CSS background-image property.

Frequently asked questions

Is my image uploaded to a server?
No. The conversion uses the browser's built-in FileReader API entirely locally. Your image never leaves your device and nothing is stored or transmitted.
What image formats are supported?
Any format your browser can display — PNG, JPG/JPEG, WEBP, GIF, SVG, BMP, ICO, AVIF, and more. If your browser can show it, this tool can encode it.
Why is the Base64 output larger than the original file?
Base64 encoding represents every 3 bytes of binary data as 4 ASCII characters, resulting in roughly 33% more data. This is a fixed overhead of the encoding scheme.
When should I use Base64 images?
Best for small icons, logos, and sprites embedded in HTML emails, inline CSS, or JavaScript. Avoids extra HTTP requests. Not recommended for large images — the file size overhead makes pages slower.
Can I decode a Base64 string back to an image?
Yes. Switch to the Decode tab, paste any Base64 string or full data URL, and click Decode. A preview appears and you can download the result as a PNG.
Is this tool free?
Yes — 100% free, no signup, no account, no ads. yhile.com is free forever.

More free tools

🔖 Bookmark this for quick access!