Image to Base64 Converter

Convert images to Base64 Data URLs for embedding in HTML, CSS, and JavaScript. Instant conversion, no upload. For developers.

Related Guide

For logos and icons, a vector file can beat any encoded image.

When should you use SVG instead?
🔒 Your images never leave your browser. Processed locally. 100% private.
🧑‍💻 Base64 encoding embeds images directly in HTML, CSS, or JSON without separate file requests. Useful for email templates, small icons, API responses, and offline apps. Note: Base64 output is ~33% larger than the original file.
🎨

Drop image to convert to Base64

JPG, PNG, WebP, SVG, GIF supported - or click to browse

Before / After
Before (original file)
Original image
After (Base64 preview)
Base64 preview
Data URL (for HTML img src)
Raw Base64 (for JSON / API)
CSS background-image
HTML img tag

→ Reverse: Base64 to Image

Paste a Base64 string or Data URL below to preview and download as an image.

How much bigger does Base64 make an image?

About a third bigger, every time. Base64 turns every 3 bytes of the file into 4 text characters, so the encoded version is 1.33 times the size of the original. We checked it on three files. A 219.3 KB PNG became 299,424 characters. A 29.6 KB WebP became 40,428. A 339.2 KB JPG became 463,104. The ratio was 1.333 in each case. The full data URL adds a short prefix such as "data:image/png;base64," on top.

When is Base64 actually worth it?

  • Tiny icons and logos of a few kilobytes, where saving a separate download matters more than a third more bytes.
  • HTML email templates and one-file documents that have to travel without separate image files. Some email clients block embedded images, so test before sending widely.
  • Test data and prototypes, where pasting a string into code is quicker than hosting a file.

It's a poor choice for photos. A 339 KB photo turns into almost half a megabyte of text inside your HTML or CSS. The browser can't cache it separately from that file, and it can't start loading it in parallel. For anything bigger than a small icon, link to a normal image file, and compress it first with the image compressor.

What formats do you get?

Four copy-ready versions of the same encoding: the full data URL, the raw Base64 string, a CSS background-image rule and an HTML img tag. The boxes on screen only show the first part of long strings to keep the page usable. The copy buttons copy the complete value. Any image type your browser recognises can be encoded, and the file never leaves your device.

Can you turn Base64 back into an image?

Yes. Paste a data URL or a raw Base64 string into the decoder box. If you paste a raw string, the tool works out the image type and wraps it for you. You'll see a preview, and you can download the decoded file. If the text isn't a valid image, it says so instead of producing a broken file.

Does encoding change the image?

No. Unlike the other tools on this site, this one doesn't redraw anything on a canvas. It reads the original bytes and encodes them as they are, so the image, its quality and any metadata inside the file are untouched. That also means EXIF data such as GPS location stays in the encoded string. Strip it first with the resizer or compressor if that matters.

How we tested: we ran this page's own code in headless Chromium using Playwright on public test images (an 800 x 600 transparent PNG, a 550 x 368 WebP photo and a 1800 x 1200 JPEG photo), and every row in the table below comes from one of those runs.

SampleSettingBeforeAfterWhat we saw
Transparent PNGEncode219.3 KB (224,566 bytes)299,424 charactersRatio 1.333
WebP photoEncode29.6 KB (30,320 bytes)40,428 charactersRatio 1.333
JPEG photoEncode339.2 KB (347,327 bytes)463,104 charactersRatio 1.333

What do people ask about Base64 images?

Base64 uses 4 text characters for every 3 bytes, so the result is always about 33 percent larger. Our 339.2 KB JPEG became 463,104 characters.
Only for very small icons. Larger images embedded as Base64 make your HTML or CSS heavier and can't be cached on their own, so normal image files load faster.
No. The file is encoded exactly as it is, metadata included. Run the image through the resizer or compressor first if you want location data removed.
Paste the data URL or raw Base64 string into the decoder box. The tool shows a preview and lets you download the decoded image.

Get fresh reads straight to your inbox

Get notified when we publish new articles. Unsubscribe anytime.