Image to Base64 Converter

Encode a picture as a data URI for CSS, HTML or JSON, or paste a Base64 string to see and save the image inside it.

Runs in your browser — nothing is uploaded

About the Image to Base64 Converter

A Base64 data URI embeds an image directly in text, so a small icon or logo can ship inside a stylesheet, an HTML template or a JSON payload without a separate request. The cost is size: Base64 writes every three bytes as four characters, so the text is about a third larger than the original file.

Use the encoder for small assets such as icons, placeholders and email graphics. Large photos are better served as normal files, because a data URI cannot be cached separately and makes the page that contains it heavier.

The decoder accepts full data URIs and raw Base64. It recognises PNG, JPEG, WebP, GIF and SVG from the first characters of the payload, then lets you download the image with the matching file extension.

FAQ

Image to Base64 Converter — frequently asked

Does Base64 make an image smaller?

No. Base64 is an encoding, not compression. It increases the size by roughly 33 percent, because each group of three bytes becomes four text characters. Compress the image first, for example as WebP or at a lower JPEG quality, and then encode the smaller file if you need a data URI.

When should I embed an image as a data URI?

Embedding works best for tiny images under a few kilobytes that appear on every page, such as a loading spinner, a small icon or a background texture. For photos or anything larger, a normal image URL lets the browser cache the file once and reuse it across pages.

Is my image uploaded when I convert it?

No. The browser reads the file with FileReader and builds the data URI on your device. The page makes no network request with your image, so private screenshots and internal diagrams never leave your computer.

What is the difference between a data URI and raw Base64?

A data URI starts with a prefix such as data:image/png;base64, that tells the browser the file type, so you can paste it into an img src or a CSS url() directly. Raw Base64 is only the encoded payload. The decoder accepts either form and detects the type when the prefix is missing.

Why does decoding fail for some strings?

Base64 may contain only letters, digits, plus, slash and up to two trailing equals signs. Spaces and line breaks are ignored, but a truncated copy will fail. URL-safe Base64 uses - and _ instead of + and /, so replace those characters first. A percent-encoded SVG data URI is not Base64 and needs its own decoder.

Which image formats can be encoded?

Any format your browser can display can be encoded, including PNG, JPEG, WebP, GIF and SVG. Formats such as HEIC or camera RAW are not shown by most browsers, so convert them to JPEG or PNG before encoding.

    Report an issue