Skip to main content
ToolsHub

Image to Base64

Encode images as Base64 strings for use in HTML, CSS, or APIs. Also decode Base64 back to images.

Files never leave your browser

Files never leave your browser

Drop an image here, or click to browse

Any image format supported

Decode Base64 → Image

How to use Image to Base64

Convert any image to a Base64-encoded string for embedding directly in HTML, CSS, or JSON — no separate image file or CDN request needed. Base64 encoding is essential for embedding icons in CSS files, storing images in JSON APIs, embedding assets in HTML email templates, and creating self-contained HTML pages.

  1. Upload your image (JPG, PNG, SVG, GIF, or WebP) using the file picker.
  2. The Base64 string and data URI are generated instantly in the browser.
  3. Copy the data URI (data:image/png;base64,...) for use in HTML/CSS img src attributes.
  4. Or copy the raw Base64 string for JSON payloads and API requests.
  5. Use the "Copy" button to copy the full string to the clipboard.

Your data never leaves your device — 100% private processing.

When to use Base64 images

Base64 images eliminate separate HTTP requests, which is beneficial for tiny icons and UI elements embedded in CSS files or inline HTML. The trade-off is a 33% increase in encoded size compared to the original binary — a 10 KB PNG becomes ~13.3 KB as Base64. For small images (under 4 KB), the savings in HTTP requests typically outweigh the size increase. For larger images, serving from a CDN with proper caching is more efficient. Base64 images cannot be cached independently by the browser because they are embedded in the parent document.

Data URI format and usage

A data URI follows the format: data:[mediatype];base64,[data]. For example: data:image/png;base64,iVBORw0KGgo... — this can be placed directly in an HTML img src attribute, a CSS background-image property, or sent in a JSON payload. SVG images can use a simpler URL-encoded format instead of Base64: data:image/svg+xml,%3Csvg..., which may be more readable and slightly smaller. For HTML emails, Base64 is required as email clients block external image requests.

Glossary

Base64
An encoding scheme that represents binary data as a string of 64 printable ASCII characters, increasing size by ~33%.
Data URI
A URL scheme (data:...) that embeds file data directly in a document rather than referencing an external file.
MIME type
A label that identifies the format of data, such as image/png, image/jpeg, or image/svg+xml.
HTTP request
A network call made by the browser to fetch an external resource — fewer requests improve page load performance.

Related reading

Frequently Asked Questions

Free · No spam

Get weekly tool tips & updates

New tools, power-user tips, and productivity hacks — delivered free every Friday.

No spam, ever. Unsubscribe with one click.

Why use Image to Base64?

  • Lossless and lossy compression options to balance quality vs file size
  • Supports all major formats: JPEG, PNG, WebP, AVIF, GIF
  • Batch operations keep filenames and folder structure intact
  • Runs client-side — no image data ever leaves your device

Common use cases

  • Resize product photos before uploading to an online store
  • Compress images to pass file-size limits on job application portals
  • Convert PNG screenshots to WebP for faster web pages
  • Create thumbnails for YouTube or social media posts
  • Remove backgrounds from profile photos

Related Image Tools

Explore all Image Tools.