Skip to main content

Base64 Image Converter

Convert images to Base64 data URLs for HTML and CSS, or decode a Base64 string back to an image. Images are processed in your browser, not uploaded.

Max 8 MB. The image stays in your browser.

Shortcuts: Ctrl+Enter run · Ctrl+Shift+C copy result · / search (use ⌘ on Mac)

Free Base64 Image Converter

Convert an image file into a Base64 data URL you can embed directly in HTML, CSS, or JSON — or paste a Base64 string to preview and download it as an image file. It helps developers embed small images in HTML, CSS, JSON fixtures, or tests when a data URI is more convenient than a separate file.

What a Base64 image data URL is

A data URL embeds a file's contents directly inside a string using Base64 encoding, in the form data:image/png;base64,<encoded data>. Browsers treat this exactly like a normal image source, so it can be used anywhere a regular image URL would go — an <img src> attribute, a CSS background-image, or a field in a JSON payload — without needing a separate network request to fetch the file.

How to use this tool

Switch to Image to Base64 and select an image file to get its data URL, ready to copy into your code, along with a live preview so you can confirm it's the right file. Switch to Base64 to Image and paste either a full data URL or a bare Base64 string to render a preview and download it back out as an image file.

Common use cases

  • Embedding a small logo or icon directly into an HTML email template, where external images are often blocked
  • Inlining a tiny placeholder image into CSS to avoid an extra HTTP request
  • Decoding a Base64 image string found in an API response or a browser devtools network payload to see what it actually is
  • Bundling a small icon directly into a JSON configuration file or a single-file HTML prototype

Everything happens locally using your browser's built-in file and image APIs — no image you convert here is ever uploaded to a server.

Worked example

Encoding a small PNG icon produces a data URL starting with data:image/png;base64,iVBORw0KGgo..., about 33% larger than the original file since Base64 always expands binary data. Pasting that same string back into Base64 to Image decodes and previews it correctly, since the data URL already declares its own MIME type.

Common mistakes and edge cases

  • Pasting a bare Base64 string (no data:image/...;base64, prefix) always gets labeled image/png regardless of the actual format — confirmed by testing. If it's really a JPEG or GIF, the preview will likely still render (browsers sniff actual image bytes), but the reported format text will be wrong.
  • The reported byte size for a decoded image is an estimate based on the Base64 string's own length and padding, not a byte-for-byte read of the decoded image — treat it as approximate, not exact.

Frequently asked questions

Why would I convert an image to Base64?
Base64-encoded images can be embedded directly in HTML, CSS, or JSON as a data URL instead of a separate file request — useful for small icons, inline email images, or bundling a tiny image with a single API response. It comes at the cost of roughly 33% larger data size than the original binary file.
Is there a file size limit?
Yes — uploads are capped at 8 MB. Base64 encoding is meant for small images like icons and logos; large photos should stay as regular image files referenced by URL.
What formats does the decoder accept?
Paste either a full data URL (starting with "data:image/...;base64,") or just the raw Base64 string on its own — the decoder detects which one you pasted and renders a preview either way.
Is my image uploaded to a server?
No. The encoding uses your browser's built-in FileReader API to read the file locally, and decoding just renders the pasted string as an image in your browser — nothing is ever sent anywhere.
If I paste a bare Base64 string (no data: prefix), how does it know the image format?
It doesn't — in practice, a bare Base64 string always gets labeled image/png regardless of what the image actually is. If it's really a JPEG or GIF, the preview will likely still render correctly (browsers sniff the actual image bytes rather than trusting the label), but the reported format text will say "image/png" even when that's wrong. Paste the full data URL (with the correct data:image/...;base64, prefix) if you need an accurate format label.
When should I use a Base64 data URI?
Use a data URI for very small images such as icons or a loading spinner, where saving a request is worth the extra size. Base64 makes the data about a third bigger and the browser cannot cache it separately, so photos and large pictures are better as normal files.

Related tools

More Frontend & Design

View all Frontend & Design tools →