DO IT EASY APP
English

Image to Base64

Turn an image into Base64 and a data URI, with ready-made HTML, CSS and Markdown snippets.

  • No sign-up, no fees.
  • Convert an image to Base64: data URI and raw text.
  • Ready-made code for HTML <img>, CSS and Markdown.
  • Copy with one click.
  • PNG, JPG, GIF, WebP and SVG; 10 MB at most.
  • Your files are processed, but never shared with anyone.

How to use the Image to Base64 tool

Embedding an image inside your code instead of as a separate file takes three steps:

  1. Choose your image. Click the box above and pick your image, or drag it onto the box. It can be PNG, JPG, GIF, WebP or SVG; 10 MB at most.
  2. Look at the outputs. The size of the file and of the Base64 text is shown. Five different outputs are prepared:
    • Data URI: in the form data:image/png;base64,...; written straight into src or url().
    • Base64 only: raw text with no header; for APIs and JSON.
    • HTML : a tag you can copy and paste into your page.
    • CSS background: a background-image line.
    • Markdown: for README and note files.
  3. Copy. Press the Copy button next to the output you want and paste it into your code.

Only the beginning of very long text is shown on screen; Copy always takes the whole text.

What is Base64?

Base64 is a way of writing binary data like an image using only letters, numbers and the + / = signs. That way an image can be placed inside a text file such as HTML, CSS, JSON or an email template. A data URI adds the image's type to the start of this text and makes an address the browser understands directly. Base64 is not encryption; anyone can decode it.

When to use it, and when not

Suitable: small icons, logos, email signatures, HTML pages that must work as a single file, small images that must show without an extra request.

Not suitable: big photos. Base64 text is about 33% longer than the file itself, isn't cached separately by the browser and slows down the first load of the page. For images larger than 100 KB, the tool warns you.

Tips for Base64 image code

The most efficient way to use Base64 is to shrink the image as much as you can before embedding it. A 2 KB icon slows nothing down when embedded; a 500 KB photo bloats the page code.

  • If the image is big, shrink it first with Compress image or Resize / crop.
  • For SVG icons, using the SVG code directly is often shorter than Base64; if you need a PNG, there's SVG to PNG.
  • For text or a file Base64, use Base64 encode / decode.
  • If you'll turn Markdown or HTML into a PDF, embedded images work in Markdown and HTML to PDF too.
  • Some email programs don't show images embedded with a data URI; send yourself a test first.

Common mistakes

  • Embedding a big photo: the page code swells by megabytes and loads slowly. Base64 image code is for small icons.
  • Forgetting the data URI header: in HTML and CSS use the version that starts with data:image/...;base64,; Base64-only text doesn't open as an image in the browser.
  • Breaking lines: splitting the text by hand breaks the image; paste it as one piece.

Frequently asked questions

Is converting an image to Base64 free?

No cost at all. Not bad, right?

Is my image uploaded to a server?

The conversion happens in your browser. Your files are processed, but never shared with anyone.

Can I turn Base64 back into an image?

If you paste the data URI into your browser's address bar, the image opens and you can save it.

Why is the Base64 text so long?

Base64 writes every 3 bytes with 4 characters; the text comes out about 33% longer than the file.

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

Base64 is just the encoded text. A data URI is that with a type header like data:image/png;base64, added in front, and it can be written straight into src.

Is Base64 encryption?

No. It's only a way of writing; anyone can decode it. Don't use it to hide something secret.

What's the biggest file I can convert?

10 MB at most. But embedding images larger than 100 KB slows the page down.

Can I use it on my phone?

Yes. Pick the image and tap the Copy button of the output you want.

Which output should I use?

HTML for an HTML page, CSS background for a stylesheet, Markdown for a README or note, Base64 only for data to be sent to an API. If you're not sure, Data URI works almost everywhere.

Can I convert an SVG file too?

Yes. SVG is converted to Base64 as well and becomes a data URI starting with data:image/svg+xml;base64,.

Related tools