Image to Base64 converter

Encode an image file as a Base64 data URI. Copy it as plain text, as an HTML image tag or as a CSS background.

or drop an image hereYou can also paste with Ctrl+V or ⌘V. JPG, PNG, WebP, GIF, SVG or any image file.

The file is encoded as it is, with no resizing or recompression. Shrink it first if the string is too long.

Your result will appear here. Nothing is uploaded: the file stays on your device.

How to convert an image to Base64

  1. Choose, drop or paste an image. JPG, PNG, WebP, GIF, SVG and other image files work.
  2. Press Convert to Base64.
  3. The data URI appears in a text box with its length in characters. Press Copy data URI, Copy as <img> or Copy as CSS.
  4. To keep the string as a file, press Download text file.

What you get

A data URI starts with data:, then the file type, then ;base64,, then the file’s bytes written as plain text. A PNG gives something like data:image/png;base64,iVBORw0…. Browsers can use that string anywhere they would use an image address.

The file is encoded exactly as it is, with no resizing or recompression. The text form is about a third larger than the file, so shrink big pictures first with the image compressor or Compress PNG.

When inlining helps, and when it hurts

Inlining suits small things: a tiny icon in a style sheet, a logo in a self-contained HTML file, or a test fixture. The picture travels inside the page, with no separate file to fetch.

Larger strings make the page heavier and cannot be cached on their own. Over about 100 KB, the tool warns you and suggests a normal image file.

What the buttons give you

Copy data URI
The bare string, ready for an src attribute, a JSON field or a script.
Copy as <img>
A complete HTML image tag with the data URI as its source.
Copy as CSS
A background-image line you can paste into a rule.
Download text file
Saves the data URI as a .txt file named after your image.

Limits

  • There are no size or quality options. Prepare the image first if it needs to be smaller.
  • The type at the start comes from what your browser reports for the file. If it reports none, the string starts with data:application/octet-stream and you may need to edit that part.
  • The image tag has an empty alt attribute. Add a description if the picture carries meaning.
  • Decoding Base64 back into an image is not offered here.

Questions

Why is the Base64 string bigger than my image?

Base64 writes binary data with a limited set of text characters, which takes about a third more space. The tool shows both sizes.

How do I use the data URI in HTML?

Press Copy as <img> and paste the tag into your page, or put the bare string inside any src attribute.

Can I convert an SVG to Base64?

Yes. The SVG file is encoded as it is, and the string starts with data:image/svg+xml;base64,.

Is my image uploaded?

No. The encoding runs in your browser, so the file stays on your device.