Image to Base64

Encode any image as a base64 data URI.

Free image to base64 encoder. Upload an image and get its base64 data URI, copy it to the clipboard or download it as a text file.

Loading tool…

If the tool stays on this message, make sure JavaScript is enabled, then reload the page.

About Image to Base64

Sometimes an image shouldn't be a separate file at all. Embedding it directly in your HTML or CSS as a base64 data URI, a long text string starting with data:image/..., means zero extra HTTP requests, which is perfect for small icons, single-file demos, and HTML emails. This tool generates that string instantly from any upload.

The output appears immediately: copy it to your clipboard or download it as a .txt file for safekeeping. Files up to 25 MB are accepted, though you'll rarely want to encode anything near that size, because base64 inflates the data by about a third.

That inflation is the reason for restraint. Base64 is wonderful for a 4 KB icon and terrible for a 2 MB photograph: the page gets heavier, and unlike a separate file, an embedded image can't be cached independently by the browser. Rule of thumb: embed the small stuff, link the big stuff, and run candidates through the image compressor first.

How to use Image to Base64

  1. Upload your image.
  2. The base64 data URI appears instantly.
  3. Copy it or download it as a .txt file.

Why use this tool?

  • One-click copy to clipboard
  • Download as .txt

Tips for best results

  • Embed small icons only: base64 shines under ~10 KB; larger images bloat pages and defeat caching.
  • Compress first: run the image through the compressor before encoding to minimize the 33% size overhead.
  • Use in CSS for tiny assets: data URIs in stylesheets eliminate requests for bullets, dividers, and icons.
  • Keep alt text in HTML: an embedded image still needs its alt attribute, the data URI replaces the file, not the markup.
  • Download the .txt: save long strings to a text file rather than keeping them on the clipboard.

Frequently asked questions

What is a base64 data URI?
A text string that embeds an image directly in HTML or CSS, like data:image/png;base64,....
Is there a file size limit?
Yes, 25MB per image. Note base64 output is about 33% larger than the original file.
When is base64 useful?
For small icons and images you want to embed directly in code without separate files.
Why is the output so long?
Base64 represents binary data as text, which takes about 33% more characters than the original file, long strings are normal.
Can I decode a data URI back to an image?
Yes, the encoding is reversible. Paste the string into any base64-to-image decoder to recover the original file.

Related tools