Image to Base64 Converter

Convert an image to a Base64 data URI to embed in code.

🔒 Files stay on your device

How to use / 使用步骤

  1. Upload an image.上传一张图片。
  2. The tool produces a Base64 data URI — copy it with one click.工具生成 Base64 数据 URI,一键复制。
  3. Paste it into your HTML, CSS or code.粘贴进 HTML、CSS 或代码中直接使用。

About Image to Base64 Converter / 关于本工具

A Base64 data URI turns an image into a long string of text that can be embedded directly inside HTML, CSS or JSON — no separate image file and no extra network request. Developers use it for tiny icons, email templates, inline SVG fallbacks, or bundling a small image into a single file. Instead of <img src="logo.png"> you write <img src="data:image/png;base64,iVBOR…"> and the picture travels with the markup.

Base64 数据 URI 把图片变成一长串文本,可直接嵌入 HTML、CSS 或 JSON——不需要单独的图片文件,也不产生额外的网络请求。开发者常用它放微型图标、做邮件模板、写内联 SVG 兜底,或把小图打包进单个文件。你不再写 <img src="logo.png">,而是写 <img src="data:image/png;base64,iVBOR…">,图片就随代码一起走了。

When to use it — and when not to / 何时用、何时别用

Base64 strings are about 33% larger than the original file, so they suit small images only. For a 2 KB icon the convenience wins; for a 2 MB photo, the bloated string slows your page and bloats your CSS — link the file normally instead. This tool reads the image locally and never uploads it, so even private images are safe to encode.

Base64 字符串比原文件大约大 33%,因此只适合小图。对 2KB 的图标,便利性占优;对 2MB 的照片,臃肿的字符串会拖慢页面、撑大 CSS——那就照常用文件链接。本工具在本地读取图片、绝不上传,因此私密图片也能放心编码。

FAQ / 常见问题

What is a Base64 image used for? Base64 图片有什么用?
Embedding small images directly in HTML/CSS without a separate file. 把小图直接嵌入 HTML/CSS,无需单独文件。
Why is the Base64 bigger than my file? 为什么 Base64 比原文件大?
Base64 encoding adds about 33% overhead. Base64 编码会增加约 33% 体积。
Is it good for large photos? 适合大照片吗?
No — use it only for small icons and assets. 不适合,仅用于小图标和小素材。

Related tools / 相关工具