Image to Base64 & Back
Turn an image into a Base64 data URL with ready HTML, CSS and Markdown snippets, or turn Base64 back into an image to view and save.
Runs in your browser. Nothing is uploaded.
How to use the Image to Base64 & Back
- Pick Image to Base64, then choose an image or drop it onto the box. PNG, JPG, GIF, WebP, SVG, AVIF and ICO all work.
- The image is previewed with its type, size and dimensions.
- Copy the format you need, such as the full data URL, plain Base64, an HTML img tag, a CSS background or Markdown.
- Edit the alt text to describe the image for the HTML and Markdown snippets.
- Keep an eye on the size note. Large images are better served as normal files.
Turn an image into text you can paste anywhere
Some places can’t link to an image file but happily accept text: an HTML email, a CSS file, a JSON API field, a Markdown document, or a single self-contained HTML page. Encoding the image as Base64 inside a data URL solves this. The picture travels inside the text itself.
Ready-made snippets
After choosing an image, you get it in every common form, each with a copy button:
- Data URL, the complete
data:image/…;base64,…value - Base64 only, just the encoded bytes, for APIs that ask for the raw value
- HTML, an
<img>tag with the data URL, your alt text and the correct width and height - CSS, a
background-imagedeclaration - Markdown, an image reference for documentation and READMEs
The MIME type is taken from the file, so the data URL is always labelled correctly.
Know the cost
Embedded images can’t be cached separately and make documents larger, by about a third over the original file size. The tool shows the encoded size and warns when it goes past 100 KB, which is roughly where a normal image file becomes the better choice. For icons and small logos, embedding is usually a good trade.
Base64 back to an image
Switch to Base64 to image and paste a data URL or plain Base64, for example from a CSS file, an
HTML email or an API response. The image type is detected from its bytes, so a missing or wrong
data: prefix doesn’t matter. You see a preview with the type, size and dimensions, and Download
image saves it with the right file extension. If the data decodes but isn’t an image, the tool says
so instead of showing a broken picture.
Private
Your image never leaves your device. It’s read locally by the browser, encoded, and displayed. To go the other way, switch to Base64 to image.
Frequently asked questions
What is a data URL?
A data URL embeds a file directly in text, in the form data:image/png;base64, followed by the encoded bytes. Browsers treat it like a link to an image file, so it can be used anywhere an image URL is accepted, such as an img src, a CSS url() or a JSON field.
When should I embed an image as Base64?
For small images like icons, logos and placeholders, embedding saves a separate network request and keeps everything in one file, which is useful for HTML emails, single-file pages and JSON payloads. For photos and large graphics, a normal file is better because it can be cached and loaded in parallel.
Why is the Base64 text bigger than my image?
Base64 uses four characters for every three bytes, so encoded data is about 33% larger. Servers usually compress text, which recovers some of that, but not all.
Will the image quality change?
No. The file's exact bytes are encoded, so decoding gives back an identical image. Nothing is resized or recompressed.
Is my image uploaded?
No. The file is read and encoded by your browser, on your device.
Tutorials
How to embed a small logo in an HTML page or email
Convert a logo to a Base64 data URL, insert it with an img tag, and understand where embedded images work and where they don't.
How to extract an embedded image from CSS or HTML
Find a Base64 image inside a stylesheet or web page, preview it, and save it as a normal image file you can edit.