Image to Base64

Encoders & Decoders

How to use the Image to Base64

Convert an image to Base64 in three steps:

1

Upload your image

Click to upload or drag and drop any image file (JPEG, PNG, GIF, WebP, SVG, BMP, ICO). A preview of the image is shown immediately.

2

Choose output format

Toggle between plain Base64 (just the encoded string) and Data URI format (data:image/png;base64,... with the MIME type prefix) depending on your use case.

3

Copy or download the output

Click Copy to send the Base64 string to your clipboard. Download saves it as a .txt file. The footer shows original size, encoded size, and size overhead.


When to use this tool

Use to embed images as inline strings in code, data, and configuration:

  • Generating data URIs for small icons, logos, or UI elements to embed directly in HTML or CSS without separate HTTP requests
  • Encoding images to Base64 for inclusion in JSON API payloads or request bodies
  • Creating Base64-encoded images for embedding in email templates where external image hosting is blocked
  • Encoding image files to Base64 for storage in databases that hold binary data as text strings
  • Generating Base64 image strings for use in React, Vue, or other framework components that need inline images
  • Preparing image data for transmission through text-only channels such as WebSocket text frames or SMS APIs

Frequently asked questions

Q:What is the difference between plain Base64 and Data URI output?
Plain Base64 output is just the encoded string — for example: iVBORw0KGgo…. A Data URI adds the MIME type prefix that browsers need to render the image inline: data:image/png;base64,iVBORw0KGgo…. Use Data URI format when embedding in HTML src attributes, CSS background-image, or anywhere a browser needs to display the image directly. Use plain Base64 when the MIME type is handled separately, such as in API payloads or database storage.
Q:What image formats are supported?
The following image formats are supported for upload: JPEG (.jpg, .jpeg), PNG, GIF (including animated), WebP, SVG, BMP, and ICO. The MIME type is automatically detected from the file's type property and included in the Data URI prefix. TIFF, HEIC, and RAW formats are not supported as they cannot be read by the browser's FileReader API natively.
Q:Why does the Base64 output become so large?
Base64 encoding increases size by approximately 33% because every 3 bytes of binary data are encoded as 4 ASCII characters. A 100KB PNG image becomes approximately 133KB as a Base64 string. For large images, this overhead makes inline embedding impractical — Base64 embedding is best suited for images under 10–20KB. For larger images, host them as separate files and reference them via URL.
Q:Is my uploaded image sent to a server?
No — the image never leaves your device. The conversion is performed entirely in your browser using the FileReader API, which reads the file locally and encodes it in memory. No image data is transmitted to any server, logged, or stored. You can safely convert confidential images, screenshots, or sensitive graphics without privacy concerns.
Q:Can I embed the output directly in an HTML img tag?
Yes — select Data URI output and the result is ready to paste directly into an HTML img tag's src attribute: <img src="data:image/png;base64,iVBOR...">. For CSS background images use: background-image: url('data:image/png;base64,iVBOR...'). Make sure there are no line breaks in the Base64 string when using it in HTML or CSS attributes.
Q:Does the tool work with SVG files?
Yes — SVG files are supported and encoded as data:image/svg+xml;base64,... in Data URI mode. Note that for SVG specifically, there is often a more efficient alternative to Base64 encoding: URL-encoding the raw SVG text as data:image/svg+xml,%3Csvg... avoids the 33% size overhead of Base64. This tool produces the Base64 variant; for URL-encoded SVG data URIs, use the URL Encoder tool.