Tools / Image ↔ Base64 (Data URI)

Image ↔ Base64 (Data URI).

Turn an image into a Base64 data URI for CSS and HTML, or preview a data URI as an image.

Runs in your browser

Encode: image file → data URI. Decode: data URI or Base64 → image.

or drop a file here

Ctrl/⌘ + Enter to run · Ctrl/⌘ + Shift + C to copy the result

Result
Preview
Data URI
CSS / HTML / Markdown
Details

About Image ↔ Base64 (Data URI)

This tool converts an image file into a Base64 data URI and turns a data URI back into a viewable, downloadable image. Drop a PNG, JPEG, GIF, WebP, AVIF, BMP, ICO or SVG file and you get the complete data:image/…;base64,… string plus ready-to-paste snippets for a CSS background-image, an HTML img tag with width and height filled in, and Markdown. The file type is detected from the file's magic bytes rather than its extension, so a PNG renamed to .jpg still gets the correct MIME type, and the dimensions are read straight from the image header. In decode mode, paste a data URI or bare Base64 and the tool shows the picture, its real format and size; it warns when the URI claims one type but the bytes are another, which is a common reason an inline image does not render. Percent-encoded SVG data URIs such as data:image/svg+xml,%3Csvg… are supported too. The details panel shows the overhead: Base64 makes data about 33% larger, and the data URI cannot be cached separately by the browser, so inlining pays off only for small assets such as icons, tiny placeholders or images in HTML emails, typically under a few kilobytes. Typical mistakes are inlining large photos (which bloats CSS and delays rendering), forgetting the data:image/png;base64, prefix, and leaving line breaks inside the Base64 in CSS. Files up to 10 MB are accepted. Encoding and decoding happen in your browser; the image is never uploaded.

How to Use

  1. Choose encode and drop an image, or choose decode and paste a data URI or Base64 string.
  2. Check the preview, the detected type, dimensions and size overhead.
  3. Copy the data URI or a CSS/HTML snippet, or download the decoded image.

Frequently Asked Questions

When should I inline an image as a data URI?

For very small images such as icons, 1×1 placeholders or images in HTML email. Base64 adds about a third to the size and the image cannot be cached on its own, so larger images are better served as files.

Why does my data URI not display?

Usually the prefix is missing or wrong (for example image/jpg instead of image/jpeg, or a PNG labelled as SVG), or the Base64 was truncated. Decode mode shows the real type and warns about mismatches.

Can I use SVG without Base64?

Yes. SVG is text, so data:image/svg+xml, followed by the percent-encoded markup is often smaller than Base64. Decode mode reads both forms.

Is my image uploaded?

No. The file is read and encoded in your browser.

Related Tools