How to use Convert Image to Base64
- 1. Choose an image. Open or drag PNG/JPG/WebP (and other formats).
- 2. Copy the string. Raw Base64 or `data:image/…;base64,…`.
- 3. Paste into HTML/CSS/JS. Use the HTML or JSX presets for ready-made tags.
About this tool
Long-tail searches like “convert image to base64 string online” want a zero-friction converter. This landing opens File encode with image accept so you are one drop away from a string.
When not to embed images as Base64
Large photos bloat HTML and defeat caching. Prefer Base64 for tiny icons, email clients that block remote images, or throwaway demos.
Code examples
Node
Buffer.from("hello").toString("base64");
Buffer.from(b64, "base64").toString("utf8");Browser (UTF-8 safe)
btoa(unescape(encodeURIComponent(text)));
decodeURIComponent(escape(atob(b64)));Python
import base64
base64.b64encode(b"hello").decode() # aGVsbG8=
base64.b64decode("aGVsbG8=").decode()Data URI
const uri = `data:image/png;base64,${b64}`;
// <img src={uri} /> or CSS url('${uri}')