Encode an image as a Data URI, raw Base64, an HTML tag or CSS, or decode Base64 back into an image. Everything runs locally in your browser.
Drop an image here or click to choose
PNG, JPEG, GIF, WebP, SVG, AVIF, BMP, ICO
Base64 turns the bytes of an image into plain text. That text can be placed in a Data URI, so a small
image can live directly inside HTML, CSS or JSON without a separate file request. This tool encodes
an image into a Data URI, raw Base64, a ready-made <img> tag or a CSS
background-image rule, and decodes Base64 text back into a viewable, downloadable
image.
Encoding and decoding both happen in your browser. The image and the text are never uploaded, so you can safely decode Base64 copied from logs, API responses or emails.
<img> tag or a CSS
background-image rule..txt file.data:image/) or raw Base64 text.| Output | Looks like | Use it for |
|---|---|---|
| Data URI | data:image/png;base64,iVBOR... | Anywhere a URL is
accepted: src, CSS url(), JSON fields |
| Raw Base64 | iVBOR... | APIs and config files that ask for the Base64 data only |
| HTML <img> tag | <img src="data:..." alt=""> | Pasting straight into an HTML page or email template |
| CSS background-image | background-image: url("data:..."); | Small icons and patterns in a stylesheet |
Inlining saves a network request, which helped page speed a lot in the past. With modern HTTP the saving is small, and inlined images have real costs: the text is about a third larger than the file, it cannot be cached separately from the page or stylesheet, and it makes the HTML or CSS heavier to download and parse.
Before inlining, make the image as small as possible with the Image Optimizer or, for vector icons, the SVG Optimizer.
-
and _).No. Both directions run in this tab. Nothing you drop or paste is sent to a server.
Base64 uses four text characters for every three bytes of data, so the result is about 33 percent larger than the file. That is how the encoding works, not a problem with the image.
A Data URI adds a prefix such as data:image/png;base64, that tells the browser the file
type. Raw Base64 is only the encoded data. Browsers need the Data URI form; many APIs want the raw
form.
Check that the whole string was copied, including the end. Strings cut short, or with extra characters
such as quotes or a JSON key, will not decode. Line breaks and the URL-safe characters -
and _ are fine.
Yes. SVG is accepted and the Data URI uses the image/svg+xml type. For SVG, optimizing the
file first with the SVG Optimizer usually saves more than any other
step.
Back to all tools.