Skip to content
🖼️

Image to Base64

Turn an image into a data URI you can paste straight into CSS or HTML.

Runs in your browser

Updated

📷

Drop an image here or click to browse

Everything happens in your browser. The file is never uploaded.

Data URI

Data URI size

0 B

Original file

0 B

Overhead

0%

MIME type

-

Preview

Converted data URI preview
64px
Converted data URI preview large
natural

Snippets

A data URI adds roughly a third to the file size on top of the base64 payload, because base64 encodes three bytes as four characters. That is fine for icons and sprites, but a data URI over about 10 KB is usually better served as a real file, because it cannot be cached separately and is re-sent with every request that uses the stylesheet.

One file, one data URI

The tool reads the image with the FileReader API and returns the full data URI: the MIME type, a base64 marker and the encoded bytes. It does not re-encode, resize or compress, so the embedded image is byte-for-byte the file you selected. That makes it reliable for tiny icons, email signatures and CSS backgrounds where the exact pixels matter.

How much bigger does it get

Base64 uses four characters to carry three bytes, so the text is about 33% longer than the binary file. A 30 KB PNG becomes roughly 40 KB of characters before any quoting overhead. The panel shows the original size, the URI length and the percentage increase, and a warning appears once the URI passes 10,240 characters because long data URIs are hard to read and slow to paste.

Ready-to-paste snippets

Alongside the raw URI the tool builds an HTML image tag and a CSS background rule with the URI already substituted. The class name in the CSS snippet is derived from the file extension, so icon.png becomes a rule named after png. Copy buttons sit next to each output.

Where it stops

  • There is no automatic minification; embedding a photograph will produce an enormous string and a poor page.
  • Selecting the same file twice in a row does not fire a change event, so choose another file or reload first.
  • The clipboard call has no fallback and fails silently outside a secure context.
  • No size cap and no warning above the 10 KB threshold beyond the amber note.

Questions people ask

Should I inline every image?

No. Inline only small, frequently used assets. Large data URIs block HTML parsing and cannot be cached separately.

How do I decode a data URI back to a file?

Use the base64 to image tool. For text rather than files, the base64 encoder is the general-purpose version.