Image to Base64 Converter

Turn an image into a data URI, a raw Base64 string, an HTML img tag or a CSS background rule, with the encoded size and overhead shown. Free, instant and processed on your device without any upload.

Image to Base64 ConverterPrivate · runs on your device
Results

Your processed files appear here with download buttons.

How to use the image to Base64 converter

Encoding a picture takes one file and one click, and the result is ready to paste.

  1. Drop an image on the upload area or click it to choose one. The tool takes a single file at a time, and choosing another replaces the first. PNG, JPG, GIF, WebP and SVG all work.
  2. Open Output as and pick the form you need: Data URI (the default), Raw Base64, HTML <img> tag or CSS background-image.
  3. Click Convert to Base64. To try another style, change the menu and click the button again.
  4. Read the result card. It shows a thumbnail, the image size, the size of the text, the overhead as a percentage and the file type, above a read-only box holding the output.
  5. Click Copy to put the text on your clipboard, or Download to save it as a text file named after your image.

How Base64 turns bytes into text

HTML, CSS, JSON and email are text formats, and raw image bytes can break them. Base64 solves this by reading the file three bytes at a time and writing each group as four characters from a 64-symbol alphabet of letters, digits, plus and slash, with equals signs as padding at the end. As a tiny example, the three letters Man are the bytes 77, 97 and 110. Written in binary and regrouped into four 6-bit values, they become 19, 22, 5 and 46, which spell TWFu.

Four characters for every three bytes means the text is about one third larger than the file. A 3,000 byte icon becomes 4,000 characters, and a 1,000 byte one becomes 1,336. The data URI adds a short prefix such as data:image/png;base64, on top. The overhead on the result card is measured on the output you chose, so the img tag and CSS styles add a few dozen characters more. Encoded files begin with a recognisable signature: PNG starts iVBORw0KGgo, JPEG /9j/, GIF R0lGOD and WebP UklGR.

The file is read with the browser FileReader and the original bytes are encoded untouched. Nothing is re-compressed, so any EXIF metadata inside a photo, including GPS position, travels inside the string. Clean the picture first with the EXIF remover if that matters.

When inlining helps, and when it does not

An inline image saves one network request, which pays off in particular cases:

  • Small icons and logos of a few kilobytes, where the request costs more than the bytes.
  • Background images inside a stylesheet, which are then cached together with the CSS file.
  • Single-file HTML pages, reports and offline demos that must work without other assets.
  • JSON payloads, test fixtures and code samples where hosting a separate file is awkward.

Larger pictures are a poor fit. An image inside an HTML page cannot be cached on its own, so it is downloaded again on every visit, and it makes the page about a third heavier than the file itself. A common rule of thumb is to inline only images under about 10 KB. Shrink the source first with the image compressor if the string is too long.

Test before relying on data URIs in email, because several major webmail and desktop clients block or strip them. Strict content security policies can also block them unless data: is allowed for images. For plain text rather than pictures, use the Base64 encoder and decoder.

Using the output and its limits

The HTML option produces an img tag whose alt text is the file name without its extension, so replace it with a proper description. The CSS option produces a ready background-image: url("data:..."); declaration. The converter works in one direction and does not turn Base64 text back into a picture. SVG files are encoded as they are; for SVG an URL-encoded form is often smaller than Base64, and the URL encoder can produce one. Very large files make a very long string that slows editors and browsers, so keep the input small, or convert a different format first with the image converter when a smaller type suits.

Quick answers

Frequently asked questions

The questions people ask most, answered in plain words.

How do I convert an image to a Base64 string online?

Drop your image on the upload area, choose a style in Output as, then click Convert to Base64. The encoded text appears in a box below with Copy and Download buttons. The file is read by your browser with the FileReader API, so it is never sent to a server.

Why is the Base64 text bigger than my image file?

Base64 writes every three bytes of binary data as four text characters, so the output is about 33 percent larger than the original, plus a short prefix for data URIs. That is the cost of making binary safe for text formats. The result card shows the exact overhead for your file and output style.

Can I use a Base64 image in an HTML img tag?

Yes. Choose the HTML img tag output and paste it into your page. The src attribute holds a data URI beginning with data:image/png;base64, or the matching type, and modern browsers render it without a separate request. Replace the generated alt text with a real description for accessibility.

Is converting an image to Base64 safe for private pictures?

The conversion happens in your browser, so the image never leaves your device. Remember that Base64 is an encoding, not encryption: anyone who gets the string can decode it back to the picture, and any EXIF data in the original is still inside it. Treat the output as carefully as the file.

How large an image can I convert to Base64?

There is no fixed limit, because no server is involved. The limit is your browser memory and how much text the page can handle comfortably. A few megabytes encode quickly, but a string that long is rarely a good idea. For anything beyond a small icon, link to the image file instead.