Skip to content

Image to Base64 Converter

Turn an image into a Base64 string or data URI you can paste straight into HTML, CSS, JSON or an email template. Encoded on your device — the image is never uploaded.

PNG, JPG, GIF, WebP, SVG, ICO or AVIF. Encoded on your device.

Embed an image as text

Base64 turns any file into plain text made of letters, digits, + and /. Wrapped in a data URI, the browser can show it without a separate request — handy for HTML email signatures, inline SVG icons, single-file reports, test fixtures and JSON APIs that only carry text.

How to convert an image to Base64

  1. Add an image. Drop, paste (Ctrl+V / Cmd+V) or choose a PNG, JPG, GIF, WebP, SVG, ICO or AVIF file.
  2. Pick the output. Choose Data URI, Base64 only, an HTML <img> tag, a CSS background rule, Markdown or JSON.
  3. Copy or save. Click Copy, or download the text as a .txt file.

Snippet examples

<img src="data:image/png;base64,iVBORw0KGgo…" alt="Logo" />

.icon { background-image: url("data:image/svg+xml;base64,PHN2Zy…"); }

{ "filename": "logo.png", "data": "iVBORw0KGgo…" }

Going the other way? Use Base64 to Image. To shrink an image before encoding it, run it through the Image Compressor or convert it to WebP first — a smaller file means a much shorter string.

Related tools and guides

Image to Base64 FAQ

What's the difference between a data URI and plain Base64?

A data URI adds a prefix with the file type, such as data:image/png;base64, — browsers need it in an <img src> or CSS url(). Plain Base64 is just the encoded bytes, which APIs and JSON fields usually expect.

Are my images uploaded?

No. Encoding and decoding happen with JavaScript in your browser. Nothing is sent to a server or stored.

Why is the Base64 bigger than the image?

Base64 writes every 3 bytes as 4 text characters, so the text is about 33% larger than the file. That's the price of putting binary data inside HTML, CSS, JSON or email.

When should I inline an image as Base64?

For small icons, logos in HTML emails, single-file HTML reports and API payloads that only accept text. For normal website images, a regular file is better because browsers can cache it and load it in parallel.

Is there a size limit?

Files up to 20 MB are accepted, but anything above a few kilobytes is usually better as a normal file. The tool warns you when the output gets large.