Image ⇄ Base64 Converter

Encode a local image as a Base64 data URI, or paste Base64 and get the image back. Both directions run in your browser, so the file never leaves your device.

Direction
Output format
Image
Drop an image here, or choose a file PNG, JPEG, WebP, GIF or SVG · read locally, never uploaded

No image decoded yet.

Base64

About this tool

A Base64 data URI embeds the whole image in the text itself, in the form data:image/png;base64,… . That makes a resource self-contained: a page can show an icon without a second request, and a single HTML file or email template can carry its own images. Base64 is an encoding, not encryption — anyone who has the text can decode the image.

The cost is size. Base64 turns every 3 bytes of binary into 4 text characters, so the encoded string is roughly 33% larger than the file, and the browser must decode it before drawing. For a favicon or a small logo that is a good trade; for a photo several megabytes long, referencing the image as a file is faster and easier to cache.

This converter reads the file through the browser’s FileReader API and never sends it anywhere. For the reverse direction it accepts either a complete data URI or raw Base64; raw text carries no media type, so the image type selector tells the browser how to interpret it.

A data URI embeds a file inside the document instead of pointing at it. The format is a MIME type, an optional encoding marker and the payload, for example data:image/png;base64, followed by the encoded bytes. Because the text travels with the HTML or CSS, the browser needs no second request to render the image, which helps for tiny assets such as icons, separators, placeholders and images used inside email templates where external hosting may be blocked.

The cost is size and cacheability. Base64 represents every three bytes as four characters, so the payload grows by roughly a third, and that overhead lands in the HTML or CSS file itself, which is usually the render-blocking resource you least want to enlarge. Images that are compressed as binary — JPEG, PNG, WebP — do not shrink when the base64 text is gzipped, because the underlying data is already dense. A separate image file, by contrast, is cached independently, downloaded in parallel and revalidated only when it changes, so inlining a 200 KB photo is almost always slower than linking to it.

There are practical traps worth knowing. Every time the encoded string appears twice on a page, the browser stores a second copy of the decoded bytes in memory, so a large inline image used in a repeated card can multiply memory use. SVG is usually better embedded as markup or as a URL-encoded data URI, because the base64 form hides the path data from compression and from search engines. And when decoding back to a file, check the declared MIME type against the actual magic bytes: a mislabelled payload will still download, but some viewers will refuse to open it.

How to use

  1. Pick a direction: Image → Base64 to encode a file, Base64 → Image to decode text you already have.
  2. Choose an image, or drop it on the target area. The file is read locally and its name, type and size are shown.
  3. Copy the Base64 text, or download it as a .txt file; switch between the full data URI and the bare Base64 as your target code requires.
  4. To go the other way, paste a data URI — or raw Base64 plus the correct image type — and the preview, decoded size and download link appear.
  5. For encoding, prefer small files under roughly 10–20 KB. Anything larger is better served as a separate file so it can be cached, compressed and loaded in parallel.
  6. For decoding, confirm the output format from the data URI header, download the file, and open it once to make sure the payload was not truncated during copy-paste.

FAQ

How much larger does an image get as Base64?

About one third. Each group of three binary bytes becomes four characters, so a 30 KB icon is roughly 40 KB of text. The data URI prefix adds a few dozen characters, which is negligible unless the image itself is tiny.

Where can a data URI be used?

In an img src attribute, in CSS as url(data:image/png;base64,…), in an SVG href, and in HTML email where external images are often blocked. It works anywhere a URL is accepted, but a long string cannot be cached separately, so repeat use is more efficient as a normal image file.

Why do I need to choose an image type for raw Base64?

Base64 encodes bytes only; it does not record what the bytes are. A data URI carries the media type in its prefix, but bare Base64 does not, so the browser needs to be told whether the result is a PNG, JPEG, WebP, GIF or SVG before it can display it.

Is converting an image to Base64 safe?

Nothing is uploaded, so the file stays on your device. Remember that Base64 is not protection: it can be decoded by anyone who receives the string, so do not use it to hide sensitive images — that needs real encryption.

Does base64 make the image bigger?

Yes, by about 33 percent. Three bytes of binary data become four ASCII characters, and line breaks or padding can add a little more. The encoded text also cannot be compressed much further, because the original image data was already compressed.

Should I inline images to reduce HTTP requests?

Only for very small assets. With HTTP/2 and HTTP/3 many requests are cheap, while an inlined image inflates the HTML or CSS that blocks rendering and cannot be cached on its own. The usual rule is to inline below about 4–10 KB and link everything else.

Can I paste the data URI directly into HTML or CSS?

Yes. Use it as the src of an img element or inside url() in CSS. Keep the whole string intact, including the data: prefix and the base64, marker, and avoid inserting spaces or line breaks in the middle of the payload.

Is it safe to encode private images here?

Yes. The conversion runs inside the browser with the FileReader API, and nothing is uploaded. The resulting text is as sensitive as the image itself, so avoid pasting it into chat tools or public issue trackers.