Skip to content
cliplimeClipLime

Convert an image to Base64

Get a data URI, an HTML img tag or CSS for any image.

Your text and files stay in your browser

Choose an image to turn into Base64

or drop it here, or paste from the clipboard

PNG, JPG, GIF, WebP, SVG, AVIF, ICO and more, up to 50 MB. It never leaves your device.

At a glance

What it does
Turns an image into a Base64 data URI, and gives you the HTML, CSS and Markdown to use it.
Formats
PNG, JPG, GIF, WebP, SVG, AVIF, ICO and more. The type is read from the file's bytes.
Outputs
Data URI, HTML img tag with width and height, CSS background-image, Markdown image, or the bare Base64.
Shows
A preview, the pixel size, the file size and the size of the text you will paste.
Limit
Images up to 50 MB, although inlining anything that large is rarely a good idea.
Privacy
The image is read in your browser and never uploaded.

How to do it

  1. 1

    Choose an image

    Pick a file, drop one onto the box or paste an image from the clipboard.

  2. 2

    Check the preview

    Confirm it is the right picture and look at the file and text sizes.

  3. 3

    Pick an output

    Choose Data URI, HTML img, CSS, Markdown or Base64 only. For HTML and Markdown you can add alt text.

  4. 4

    Copy it

    Press Copy and paste the result into your page, stylesheet or document.

When inlining an image as Base64 is worth it

A data URI puts the image inside the page itself, so the browser needs no extra request to show it. That helps for small things:

  • Tiny icons and logos of a few kilobytes, where the extra request costs more than the extra bytes.
  • Single-file pages and demos that must work as one file, such as a saved report or a bug reproduction.
  • Placeholders shown while a larger image loads.
  • Markdown and documentation that should carry its images with it.

When it is not

Base64 makes the data about 33% bigger, and an inlined image cannot be cached on its own: it downloads again with every page that contains it. Inside a stylesheet, a large data URI also delays the rendering of everything that depends on that stylesheet. As a rule of thumb, keep inlined images small and serve larger ones as normal files.

Many email clients also do not show images that are inlined as data URIs, so for HTML email, attach the image or link to a hosted copy instead.

Using what you copy

  • Data URI: data:image/png;base64,... works in places that take a URL, such as the src of an img or a CSS url().
  • HTML: a complete img tag with width, height and the alt text you type. Always write alt text for pictures that carry meaning.
  • CSS: a background-image: url("data:..."); line to paste into a rule.
  • SVG: these are text already, so they can be smaller as a percent-encoded data URI than as Base64. The Base64 form is still valid and works the same.

To get the picture back out of a data URI, use Base64 to image.

Questions people ask

What is a data URI?

A way to write a file directly into a URL, in the form data:[type][;base64],data. The browser reads the image from the text itself instead of downloading it from a server.

Does converting to Base64 change the image?

No. The bytes of the file are encoded exactly as they are, with no recompression, so decoding gives back an identical file.

How much bigger does the image get?

About a third bigger, because 3 bytes become 4 characters. The tool shows the exact size of the file and of the text.

Which image types does it accept?

Any image your computer has. The type is detected from the file's bytes, so a wrongly named file is still handled correctly. Your browser may not be able to preview formats like HEIC, but the Base64 is still an exact copy.

Is my image uploaded?

No. The file is read and converted in your browser and nothing is sent anywhere.