Image to Base64

Encode a JPEG, PNG, or WebP to a data URL or raw Base64, and decode one back, in this browser. SVG is refused.

Last updated: October 5, 2026

Tool

This tool will load here.

What this image to Base64 tool does

This page covers two jobs that people split across two tools: encode a local image to a data URL or raw Base64, and decode a data URL or Base64 string back to a file. Both stay in the browser. Encode reads the original file bytes. It does not re-encode through canvas, so the Base64 matches the file you chose. Decode accepts data:image/jpeg, data:image/png, or data:image/webp, or raw Base64 of those types. The payload is sniffed again. SVG data URLs are refused.

A data URL is the MIME type plus Base64 in one string. CSS background-image and some markdown hosts accept that form. Raw Base64 is the same payload without the prefix. Copy writes the data URL. If you needed a different container before you embed, convert with the Image Format Converter first, then encode the new file.

How to use

  1. To encode, choose a JPEG, PNG, or WebP and press Encode. Copy the data URL if you need the prefixed form.
  2. To decode, paste a data URL or raw Base64 and press Decode. Download writes a local file after the bytes sniff as a supported image.

Empty selection, unsupported type, oversized file, and bad Base64 are errors. Decode text larger than about 12 MB of characters, or a payload larger than 8 MB of bytes, is refused. The output boxes are readonly text. Filenames and payloads are never written with innerHTML.

Example

A 40 KB PNG icon becomes a data:image/png;base64,… string you can paste into a CSS file. A pasted data URL that starts with data:image/svg+xml is refused. A JPEG data URL that was truncated in email decode fails instead of drawing a broken picture into the page HTML. The preview uses a canvas after a safe decode.

Limits

  • JPEG, PNG, and WebP only. No SVG.
  • Encode uses original bytes. Decode sniffs magic bytes again.
  • 8 MB file / payload cap.
  • Work stays in this browser. Nothing is uploaded.

A huge data URL in a stylesheet will hurt parse time. This page will not stop you from copying a 4 MB string, but that is usually the wrong place for a hero photo. Use a file URL or a CDN object for large pictures. Do not paste untrusted Base64 from chat into a page you serve to other people without treating it as untrusted input. This tool is for local conversion, not for sanitizing someone else’s payload on a server.

Decode does not assign img.src to the pasted string. The payload is decoded to bytes, sniffed, turned into a Blob, then decoded again through the same image loader the other tools use. That extra step blocks a data:text/html trick and blocks SVG. If the prefix says image/png and the bytes are JPEG, the page refuses the mismatch.

Whitespace in a pasted string is stripped before atob. That helps with mail-wrapped Base64. It will not repair a string that lost the last twenty characters. A failed atob is a decode error. An empty box is an empty-selection error. There is no “best effort” preview that injects the paste into the DOM.

Image to Data URL is not a second published page. The data URL is the Base64 with a prefix. One engine key, one URL, two output boxes. If you only needed a different file type, convert first. If you only needed dimensions, use the checker. This page is for the embed string and for getting a file back from one.

On this page

Related Articles

Related solutions

Need another tool ?

Open the free tools — no signup.

FAQs

newsletter signup

Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Innovative Solutions For Modern Needs
Copyright © 2026 Yallasolve. all rights reserved.