Loading tool…

Convert Image to Base64

Convert image to Base64 online — drop the file, copy the encoded string or Data URI. Free, no account, nothing uploaded.

How to use Convert Image to Base64

  1. 1. Choose an image. Open or drag PNG/JPG/WebP (and other formats).
  2. 2. Copy the string. Raw Base64 or `data:image/…;base64,…`.
  3. 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}')

This is one direction of Base64 Studio. The editor is the same; the title and default direction match this search.

Frequently asked questions

Related tools

All tools