Image to Base64

Convert any image to Base64 data URI instantly. Copy the encoded string for CSS backgrounds, HTML img tags, or embed directly in JSON and code.

PNG · JPG · GIF · SVG · WebPInstant encodingNo upload

① Drop or select an image file ② Choose output format (Base64 / Data URL) ③ Copy the encoded string

Drop image herePNG, JPG, GIF, SVG, WebP — or click to browse
How it works

The FileReader API reads your image file and converts it to a Base64-encoded data URI. Everything runs in the browser — your file never leaves your device.

What is Base64?

Base64 encodes binary data as ASCII text, using 64 printable characters. A data URI combines the MIME type and Base64 string into a single embeddable string starting with data:.

When to use it

Use Base64 images to eliminate HTTP requests for small icons, embed images in CSS, store images in JSON APIs, or use in email HTML where external images are blocked.

Image to Base64 — how data URI encoding works

Base64 encoding converts binary data (like image files) into a text string using only ASCII characters. A Data URL (data:image/png;base64,…) embeds the encoded data directly into an HTML or CSS file, eliminating the need for a separate HTTP request. The browser's FileReader API reads the file and produces the string entirely client-side. Use it for small icons in <img src="data:..."> tags, CSS background-image, or JSON APIs. The encoded string is approximately 33% larger than the original binary, so Base64 is best used for files under 10–20 KB.

Frequently asked questions

Base64 encoding converts binary image data into a string of ASCII characters. A data URI wraps this string with a MIME type prefix (e.g. data:image/png;base64,...) so it can be used anywhere a URL is expected — directly in HTML src attributes, CSS background-image, or JSON.
The browser's FileReader API reads the file as a binary buffer, then encodes every 3 bytes of binary data as 4 Base64 characters, using the A–Z, a–z, 0–9, +, and / character set. The result is a self-contained string that includes the file type and all pixel data.
A Base64 string is just the raw encoded data. A data URI is the complete embeddable string: data:[MIME type];base64,[Base64 string]. To use an image in HTML or CSS you need the full data URI. The raw Base64 string is used in JSON APIs or when constructing the URI manually.
Any image format the browser can read works: PNG, JPG/JPEG, GIF, SVG, WebP, BMP, ICO, and AVIF (in supporting browsers). The MIME type is automatically detected from the file and included in the data URI prefix.
Base64-encoded images are approximately 33% larger than the original binary file. They cannot be cached by the browser separately and will be re-downloaded on every page load. Best practice is to use Base64 only for images under 10–20 KB. Larger images should use standard file URLs or a CDN.
In CSS, use: background-image: url('data:image/png;base64,...'). This tool provides the 'Copy as CSS background' button which formats the value ready to paste into your stylesheet.
No. The entire conversion runs in your browser using the FileReader API. Your image file never leaves your device and is not uploaded to any server.

Explore Our Network