Image to Base64

Free online image to Base64 converter. Supports JPG, PNG, GIF, WEBP, SVG, and BMP with built-in compression, resize, and format conversion. All processing stays in your browser — your images never leave your device.

Choose an image or drag & drop it here
Supports JPG / PNG / GIF / WEBP / SVG / BMP · Ctrl+V to paste from clipboard

What Is Image to Base64?

Image to Base64 converts your image files into Base64-encoded strings, letting you embed image data directly into HTML, CSS, or JavaScript without extra HTTP requests. The result is a Data URI — a string that looks like data:image/png;base64,iVBOR....

How It Works

Uploaded images are read and re-rendered right in your browser using the Canvas API. Use the Quality slider (for JPEG/WEBP) to control compression, the Scale slider to resize the output, or pick a different format. Everything stays in your browser — no image data is ever sent to a server.

4 Output Formats

  • Pure Base64 — the raw Base64 string without the Data URI prefix
  • Data URI — the full data:image/...;base64,... format
  • HTML <img> Tag — ready-to-use <img src="..."> markup
  • CSS background — ready-to-use background-image: url(...) declaration

Use Cases

  • Embed small icons or logos in HTML emails so external images aren't blocked
  • Inline small images like icons or button backgrounds directly in CSS to cut down HTTP requests
  • Use images in code sandboxes like CodePen or JSFiddle without hosting them separately
  • Send small image data through JSON APIs
  • Embed screenshots in Markdown using Base64 — handy when external images aren't supported

Examples

HTML <img> Tag

<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUg..." alt="embedded image">

CSS background-image

.element {
  background-image: url('data:image/png;base64,iVBORw0KGgoAA...');
  background-size: cover;
}
Tip: Base64 encoding increases data size by roughly 33%, so it's best for small images under 10KB. For larger images, use this tool's Compression and Scale features to reduce the encoded string length significantly. JPEG and WEBP support lossy compression, letting you balance image quality against file size.

🙏 帮我们做得更好

我们是刚上线的编程教程站,几个人的小团队,精力有限。页面虽经检查,难免还有疏漏——链接失效、排版错乱、内容有误、语言生硬……

如果您发现了,麻烦告诉我们,我们会在收到反馈后第一时间进行修复,再次感谢您的光临 🙏