Image to Base64 Converter

Convert any image file to a Base64 encoded data URL for embedding directly in CSS, HTML, or JavaScript code.

Runs in your browser. No data leaves your device.

About this tool

Reads an image file with FileReader.readAsDataURL and shows its Base64 encoding in four ready-to-paste forms. The original file bytes are encoded as-is (no re-encoding), so the MIME type and file contents are kept exactly.

Features
  • Four outputs: raw Base64 string, full data URL, CSS background-image declaration, HTML <img> tag (alt = file name without extension, HTML-escaped)
  • Copy button on each output; the raw Base64 output can also be sent on to another tool
  • Shows original size vs encoded size in KB
  • Image preview
  • Drag-and-drop, click, or keyboard (Enter/Space on the drop zone) to browse
How to use it
  1. Drop an image or click to browse
  2. Copy the format you need: Base64, data URL, CSS, or <img> tag
  3. Click Clear to start over
Inputs
  • Any file whose MIME type starts with image/; one file at a time
  • No size cap
Outputs
  • Text only, copied to the clipboard; no file download
  • Output previews are truncated at 500 characters on screen, but Copy copies the full string
Limits and notes
  • Non-image files are rejected with an error message under the drop zone
  • Large images give very long strings; Base64 is about 33% bigger than the file
  • Nothing is stored locally

Frequently Asked Questions

How does the Image to Base64 Converter work?

The tool reads your image file in the browser with FileReader.readAsDataURL(), which Base64-encodes the original file bytes unchanged and adds the data: prefix with the file's own MIME type. From that data URL it shows the raw Base64 string, the full data URL, a CSS background-image declaration and an HTML img tag, each with a copy button. The file is never re-encoded or uploaded.

Why would I convert an image to Base64?

Base64-encoded images can be embedded directly in HTML, CSS, or JavaScript without a separate file request. This is useful for small icons, email templates, and reducing HTTP requests on websites.

Does Base64 make the image larger?

Yes, approximately 33% larger than the original file. This is why Base64 embedding is best for small images (under 10KB). For larger images, serving them as separate files is more efficient.

What image formats can I convert?

JPG, PNG, GIF, WebP, SVG, BMP, and ICO files. The tool outputs a complete data URL string ready to paste into your code.