Tools › Build › Image to Base64 Converter
🖼️

Image to Base64 Converter – Data URI, CSS & HTML

Convert any image to a Base64 data URI and copy it as ready-to-use CSS, an HTML img tag or raw Base64. Everything runs in your browser.

✅ 100% Private
⚡ Instant
📋 CSS / HTML / Raw
🖼️
Drop your image here, click to browse, or paste it (Ctrl+V)
JPG, PNG, GIF, WebP, SVG, ICO, AVIF — up to 25 MB
Preview of your image

📋 File info

File name
—
File size
—
MIME type
—
Dimensions
—
Base64 size
—
Size increase
—
Advertisement

How to use

  1. Drop an image on the box, click to browse, or paste one with Ctrl+V.
  2. Check the file info and choose a format: Data URI, CSS, HTML or Raw Base64.
  3. Click Copy (or Download .txt) and paste it into your code.

What is a Base64 image (data URI)?

Base64 turns the bytes of an image into plain text. Wrapped as a data URI (data:image/png;base64,…) it can be placed straight into HTML, CSS, JSON or an email, so the browser does not need a separate request to load the file. This tool reads your image locally and gives you the finished string.

When should I use Base64 images?

  • Good for: tiny icons, logos and simple graphics under about 10 KB; single-file HTML pages; HTML email templates; CSS that must be fully self-contained; embedding images in JSON or Markdown.
  • Avoid for: photos and large images — Base64 makes files about 33% bigger, blocks separate browser caching and slows rendering.

How to use the result

HTML: <img src="data:image/png;base64,…" alt="">. CSS: background-image: url('data:image/png;base64,…');. Use the Raw Base64 tab when an API asks only for the encoded string without the data: prefix.

Frequently asked questions

Is my image uploaded to a server?

No. The conversion runs entirely in your browser using the FileReader API. Your image never leaves your device.

Why is the Base64 text about 33% bigger than my image?

Base64 represents every 3 bytes of data as 4 text characters, so the output is always about one third larger. That is why it is best for small images.

What is the difference between a data URI and raw Base64?

A data URI includes the prefix data:image/png;base64, that tells the browser the file type. Raw Base64 is only the encoded characters. Use the data URI for HTML and CSS, raw Base64 for APIs and databases.

Which image formats are supported?

JPG/JPEG, PNG, GIF, WebP, SVG, ICO, AVIF and BMP. The MIME type is detected from the file, or from the file extension when the browser does not report one.

Why is my output cut off on screen?

For very large images the on-screen preview is shortened to keep the page fast. The Copy and Download buttons always give you the complete text.

Can I convert Base64 back into an image?

Yes — paste the data URI into your browser's address bar to view it, or use the Base64 Encoder / Decoder to decode the raw string and download it as a file.