Developer Tools

Image to Base64 Converter

Convert an image to Base64 online for free: drag in a PNG, JPG, GIF, WebP, SVG, BMP or ICO and get the Base64 string, data URI, HTML img tag, CSS background and Markdown snippet instantly, or paste Base64 back to preview and download the image. 100% in your browser, no upload.

Drop an image here, click to choose a file, or paste one (Ctrl+V)

PNG, JPG, GIF, WebP, SVG, BMP, ICO. Your image never leaves your browser.

Tip: copy any image and press Ctrl+V here to paste it.

⚡ Base64 makes an image about 33% larger than the original file, so it is best for small images such as icons and logos. Use the re-encode option to convert to JPEG or WebP and lower the quality before encoding, and the stats line shows exactly how much you saved.

🔒 Privacy: encoding, re-encoding and decoding run locally in your browser. Your image is never uploaded, stored or seen by anyone else.

More developer tools

How this calculator works

An image to Base64 converter turns a picture file into a long text string you can paste directly into code. Base64 encoding represents the raw bytes of the image with 64 safe text characters, and wrapping that string in a data URI (data:image/png;base64,...) lets a browser render the image without a separate file or network request. That is why Base64 images show up in HTML emails, single-file pages, CSS backgrounds, API payloads and config files: one self-contained string replaces a file that would otherwise need hosting, a URL and a second download. Drop an image here, or paste one from your clipboard, and the converter produces the Base64 string and every ready-to-paste snippet in your browser, with a live preview so you can check the result before you copy it.

The converter gives you five outputs for the same image, so you can grab exactly the form your code needs. The raw Base64 string is the encoded bytes on their own, the data URI is the full embeddable value, and the HTML, CSS and Markdown tabs wrap it into an <img> tag, a background-image rule or a Markdown image, ready to paste. A stats line shows the original file size, the Base64 size and the overhead, which is always around 33% because three bytes of image become four characters of text. The re-encode option is what makes this converter different from a plain encoder: for raster images you can convert to JPEG or WebP and lower the quality, or cap the width, and the tool re-encodes the image in your browser before encoding it, so a 2 MB photo can become a 150 KB data URI that is actually practical to embed.

The decoder works the other way: paste a Base64 string or a full data URI and the tool validates it, sniffs the real image format from the file bytes, shows a live preview with the file size and MIME type, and lets you download the decoded image with the right extension. Your images never leave your device, encoding, re-encoding and decoding all run locally, so screenshots, logos and private photos stay private. One honest warning: Base64 is best for small images such as icons, logos and tiny illustrations. A large photo grows by a third and bloats every page that embeds it, so for photos and hero images, host the file and link to it, and reach for the Image Compressor on this site first if the file is bigger than it needs to be.

Frequently asked questions

How do I convert an image to Base64 online?
Drag an image onto the converter, click to pick a file, or paste it straight from your clipboard (Ctrl+V). The Base64 string, data URI, HTML img tag, CSS background and Markdown snippet appear instantly. Copy any of them, or download the data URI as a .txt file. Nothing is uploaded: conversion runs in your browser.
What is a data URI and when should I use one?
A data URI is a Base64 string with a prefix that tells the browser what it is, such as data:image/png;base64,iVBOR... It lets you embed an image directly in HTML, CSS or an email with no separate file. Use data URIs for small images (icons, logos, tiny illustrations) where avoiding an extra request is worth the larger size; for large photos, host the file instead.
Why is the Base64 string about 33% larger than my image?
Base64 packs three bytes of image data into four text characters, so the encoded text is always 4/3 the size of the original, plus a small amount of padding. The stats line under the output shows the exact overhead for your file. The re-encode option (JPEG or WebP with a lower quality, or a smaller width) shrinks the image itself before encoding, which is the only way to make the final string meaningfully smaller.
How do I convert Base64 back to an image?
Switch to the Decode tab and paste the Base64 string or the full data URI. The tool validates the string, detects the real image format from the file bytes, shows a live preview with the file size and MIME type, and gives you a download button that saves the image with the correct extension (PNG, JPG, WebP and the rest).
Can I make the Base64 output smaller?
Yes. Under Re-encode, pick JPEG or WebP and lower the quality, or set a maximum width. The tool redraws the image on a canvas in your browser and encodes the smaller version, so a photo can shrink by 80% or more before it becomes Base64. This works for raster images (PNG, JPG, GIF, WebP, BMP); SVG and ICO files are encoded as they are, because they cannot be redrawn reliably.
Is my image uploaded anywhere?
No. The file is read with FileReader and encoded entirely in your browser, and the re-encode step draws on a local canvas. Your image is never sent to a server, stored or seen by anyone else, so screenshots and private photos stay on your device.
Disclaimer: Results are estimates for planning purposes only and are not financial advice. Actual loan terms, taxes and investment returns vary. Consult a qualified professional before making financial decisions.