🖼️ Image to Base64 Encoder

Convert images to Base64 data URIs for embedding in HTML, CSS, or JSON. Supports JPEG, PNG, GIF, SVG, and WebP. Free online image to Base64 converter — runs in browser.

🖼️
Drop an image here or
PNG, JPG, GIF, WebP, SVG supported

How to Use

1

Upload your image

Click the upload area or drag and drop any PNG, JPG, GIF, WebP, or SVG file.

2

Choose output format

Toggle between full Data URI (data:image/png;base64,...) and raw Base64 string only.

3

Copy the result

Click Copy to clipboard. Use the data URI directly in your CSS background-image or HTML src attribute.

Frequently Asked Questions

What is a Base64 image data URI? +
A data URI embeds the image directly in your HTML or CSS as text: data:image/png;base64,iVBORw0KGgo.... This eliminates a separate HTTP request for the image file, useful for small icons, backgrounds, and email templates.
What image formats are supported? +
PNG, JPG/JPEG, GIF, WebP, SVG, BMP, ICO, and most common image formats are supported. The MIME type is automatically detected from the file and included in the data URI.
How large will the Base64 output be? +
Base64 encoding increases file size by approximately 33%. A 100KB image becomes roughly 133KB as Base64 text. For images over 50KB, linking to the file is usually better for performance than embedding.
How do I use this in CSS? +
Copy the full data URI and use it as: background-image: url("data:image/png;base64,..."); In HTML: <img src="data:image/png;base64,...">. For email templates, inline data URIs ensure images display without external loading.
Is my image uploaded to a server? +
No. The entire conversion runs in your browser using the FileReader API. Your image never leaves your device and is never sent anywhere.


完整指南:图片转Base64工具

什么时候用图片转Base64?

将图片转换为Base64字符串可直接嵌入CSS、HTML或JSON中,无需外部文件。适用于:CSS中的小图标、HTML邮件中附件可能被屏蔽的情况、需要JSON载荷中包含二进制数据的API。

缺点:图片大约增大33%且无法单独缓存——仅用于小资源(<5KB)。

如何使用

  1. 拖放或上传图片(PNG、JPG、SVG、GIF)。
  2. 完整的data URI自动生成。
  3. 复制直接在CSS/HTML中使用。

专业技巧

🧰 50+ Tools