Home › File & PDF Tools › Image to Base64

Image to Base64

Sometimes an image needs to travel as text — inside an HTML file, a CSS rule, a JSON payload, or an email template. This free image to base64 converter turns PNG, JPG, WebP, GIF and SVG files into a data URL or a plain base64 string, and decodes base64 back into a downloadable image. Nothing leaves your device.

Direction
Drop an image here or click to browse — PNG, JPG, WebP, GIF or SVG

No image selected yet
Choose an image and its base64 appears instantly — or switch direction to decode.

Nothing leaves your device. The conversion happens in your browser — your image and its base64 are never uploaded.

How it works

Base64 is a way of writing binary data using only 64 safe text characters — the letters, digits, and a couple of symbols that survive any text system. The encoder groups your file's bytes three at a time and writes each group as four characters, which is why the output is predictably about a third longer than the input. Your browser already knows how to do this: reading the file produces the encoded text directly, with no server and no library involved.

Data URL = "data:" + the image's format + ";base64," + base64(file bytes)  |  Base64 length = 4 × ⌈file bytes ÷ 3⌉  |  Overhead ≈ +33%

The tool shows both products because they serve different masters. The data URL is the embeddable one: paste it into an <img src="…">, a CSS background-image, or a favicon link and the browser renders the picture from the text itself. The plain base64 is what APIs, JSON fields and some email systems ask for — the same characters without the label. The stats table reads the format from the file itself and puts real numbers on the overhead for your image rather than the textbook third.

The decode direction runs the process backwards. A pasted data URL carries its own format in the prefix, so it just works; a pasted plain string arrives anonymous, so you tell the tool which format to label it — the image data is the same either way, the label just tells the browser how to interpret it. The rebuilt image previews on the page and downloads under a sensible name.

One size warning, honestly stated: base64 is for small graphics. A 2 MB photo becomes about 2.7 MB of text that also blocks the page it sits in and can never be cached on its own. For icons and logos it is a gift; for photography it is usually the wrong tool.

Worked example

A web designer has a small logo, logo.png — 4,096 bytes, the kind of file that ends up embedded in a page header. She drops it into the box: it confirms "✓ Chosen: logo.png (4.0 KB)" and fills both boxes. The plain base64 comes out at exactly 4 × ⌈4096 ÷ 3⌉ = 5,464 characters, and the data URL adds the 22-character prefix data:image/png;base64, for 5,486 characters total — an overhead of about 33.4%, which the stats table shows for her actual file. She copies the data URL into her stylesheet and the logo now travels inside the CSS, no separate file to host or lose.

Where base64 earns its keep

Email templates. Many email builders accept embedded images where hosted ones get blocked or stripped; a small logo as a data URL survives the trip. Keep it tiny — some mail systems clip long messages.

Single-file pages and documents. A report, a demo, or an offline handout that must work with no companion files can carry its few graphics inside itself.

APIs and test fixtures. When a service accepts an image as a JSON string, or a test needs a picture written as text, plain base64 is the format they mean — generate it here and paste it in.

FAQ

What is the difference between the data URL and the plain base64?

They carry the same encoded image. The plain base64 is just the encoded characters. The data URL wraps them in a short prefix — data:image/png;base64, — that tells a browser what the characters are, so it can be pasted straight into an image tag's src, a CSS background, or an HTML file and just work. Use the data URL for embedding in pages; use the plain string when an API or a JSON field asks for base64 itself.

Why is the base64 about a third bigger than the image file?

Base64 stores every 3 bytes of your file as 4 text characters, so the encoded version is always about 33% larger than the original — that is the price of representing binary data in characters that are safe inside HTML, CSS and JSON. The stats on this page show the exact overhead for your image. For big photos the extra weight (and the lost caching) usually makes a separate image file the better choice.

When should I embed an image as base64 at all?

For small, always-needed graphics — icons, logos, tiny placeholders, email images — embedding removes a network request and makes a page or email self-contained. For large or reused images it backfires: the encoded text inflates the HTML, cannot be cached separately, and is re-downloaded with every page that contains it. A common working rule is to embed only images of a few kilobytes.

Can I turn base64 back into an image file?

Yes — that is the second tab of this tool. Paste a data URL or a plain base64 string, and the tool rebuilds the image, previews it, and offers it as a download. For a plain string with no prefix, pick the image format it belongs to (PNG is the default guess) so the browser labels it correctly; the image data itself is identical either way.

Is my image uploaded to a server?

No. The encoding is done by your browser reading the file locally — nothing is uploaded, stored, or shared, in either direction. Close the tab and the image and its base64 are gone.

Disclaimer: Files are processed in your browser and never uploaded. Base64 output is only as trustworthy as the file you started with — check previews before embedding the result anywhere important.