Open Toolkit

Convert an image to Base64

Base64, a data URI, CSS, or an HTML img tag, ready to copy.

Free, no sign-up, no credit card. Your files stay on your device.

Format

How to convert an image to Base64

  1. Choose an image, or drop it on the page.
  2. Pick the format you need, such as a data URI or CSS.
  3. Copy the text, or download it as a .txt file.

What to know

Which format to copy

  • Data URI: the text with its data:image/…;base64, start. Paste it wherever a link to an image would go, such as an img src or a JSON field.
  • Base64 only: the bare text, for an API or a config file that asks for the image's bytes on their own.
  • CSS background: a whole background-image line, ready to paste into a stylesheet rule.
  • HTML <img>: a complete img tag with an empty alt. Fill in the alt text if the picture means something.

Your file, byte for byte

The image is not redrawn or compressed. Every byte of the file is written out as text, so the quality is exactly the same. Anything stored inside the file comes along too, including camera details and the place a photo was taken. The format you pick is remembered on this device for next time.

If something goes wrong

The text is too long to use

Base64 grows the file by a third, so start from a smaller file. Shrink the picture's pixel size, or compress it, then encode it again. Use Compress image.

I don't want the photo's location in the text

Remove the photo's details first, then encode the cleaned copy. Use Remove EXIF and GPS.

My HEIC photo isn't accepted

Browsers can't show HEIC outside Safari, so a data URI holding one would show nothing on most screens. Convert it to JPG first. Use HEIC to JPG.

Questions

What is a data URI?

A whole image written as text, starting with data:image/png;base64. You can put it straight into HTML, CSS, or JSON instead of linking a separate file.

Why is the text bigger than my file?

Base64 uses 4 characters for every 3 bytes, so the text is about a third larger than the image. That's why it suits small icons more than photos.

Which formats work?

PNG, JPG, WebP, GIF, SVG, AVIF, BMP, and ICO. The type in the data URI comes from the file's contents, not its name.

Are my images uploaded?

No. Your files are processed on your device. We never upload them.

Is there a size limit?

Files over 100 MB ask you to confirm before encoding, since the text can be too big for a phone's memory. Text over 200,000 characters is shown shortened on the page, but Copy and Download always give all of it.

Something not working? Report a problem