1. Home
  2. All tools
  3. Convert & optimize
  4. Image to Base64
Image ⇄ Base64

Convert an image to Base64

Embed small images directly in HTML, CSS, JSON or emails as a Base64 data URI — or turn a Base64 string back into an image file.

Nothing uploaded Free, no signup No watermark
  1. 1Add image or paste code
  2. 2Pick the output
  3. 3Copy or download

Drop your image here

Base64 is best for small images like icons and logos (under about 10 KB).

Output format

Paste a data URI anywhere a normal image URL would go.

Advertisement

How to convert an image to Base64

1
Add your imageDrop a PNG, JPG, SVG, GIF or WebP file. To go the other way, switch to "Base64 → Image" and paste your code.
2
Pick the outputChoose a full data URI, the raw Base64 text, a ready-made HTML <img> tag or a CSS background rule.
3
Copy and pastePress "Copy to clipboard" and paste the result straight into your code.

What is Base64 and when should I use it?

Base64 turns binary data, like an image, into plain text made of letters, numbers, + and /. A data URI wraps that text with the file type (for example data:image/png;base64,…) so a browser can display it without downloading a separate file.

It's handy for small images: icons in a stylesheet, a logo in an HTML email signature, placeholder images, images inside JSON or API payloads, and single-file HTML pages. Because the image travels inside the code, there's one fewer network request.

When not to use Base64

Base64 makes files about 33% larger, and an embedded image can't be cached separately by the browser — it's downloaded again with every copy of the page or stylesheet. For photos and anything over roughly 10 KB, a normal image file is faster. If your image is large, compress it first or use a regular file instead.

Using the output

  • HTML: <img src="data:image/png;base64,…" alt="…">
  • CSS: background-image: url("data:image/png;base64,…");
  • Markdown: ![alt](data:image/png;base64,…) (support varies by platform)

Frequently asked questions

Is my image uploaded?

No. Encoding and decoding happen entirely in your browser.

Why is the Base64 text so long?

Every 3 bytes of the image become 4 characters of text, so a 30 KB image becomes about 40,000 characters. That's normal — and a sign the image may be too large to embed.

Can I use Base64 images in emails?

Some email apps display them, but Gmail and several others block data-URI images. For reliable email images, host the image and link to it.

My decoded image won't show — why?

Make sure you pasted the complete string with nothing cut off, and that it really is an image. Line breaks and spaces are removed automatically.

Advertisement