Drag & Drop Image
or click to browse files
PNG
JPG
GIF
WEBP
SVG
Maximum file size: 5MB
Frequently Asked Questions
A Base64 image is a regular image file that has been converted to a text string using Base64 encoding. Instead of storing the binary image data as a file, the image data is represented as ASCII characters that can be embedded directly in code. When the browser encounters a Base64 image (called a data URI), it decodes the text back into binary image data and renders it. The visual result is identical to a regular image, but the delivery method is different. Regular images require a separate HTTP request to fetch the file, while Base64 images are embedded in the HTML or CSS itself.
Developers convert images to Base64 for several reasons. The most common is reducing HTTP requests for small images like icons and logos. Each HTTP request has overhead, and for very small files, that overhead can exceed the file size itself. Base64 encoding also works well for email templates since embedded images aren't blocked by email clients. It's useful for PWAs that need to work offline, and for dynamically generated images in Canvas or JavaScript applications. Some developers use it to simplify deployment by reducing the number of files that need to be hosted.
Yes, Base64 encoding increases file size by approximately 33%. This is because Base64 uses 64 different characters (A-Z, a-z, 0-9, +, /) to represent data, whereas normal binary uses 256 possible byte values. To represent 3 bytes of binary data, Base64 needs 4 characters. The mathematical result is that encoded data is about 133% the size of the original. This overhead is worth it for small images where the HTTP request overhead would be larger, but it's counterproductive for large images where the 33% increase is significant.
Use the data URI format in your CSS background-image property. The syntax is: background-image: url("data:image/png;base64,iVBORw0KGgo..."). Replace "image/png" with the appropriate MIME type (image/jpeg, image/gif, image/svg+xml, etc.) and paste your Base64 string after "base64,". You can use this for any CSS property that accepts an image, including background-image, list-style-image, and border-image. The image renders identically to a regular URL-based image.
Use the data URI as the src attribute in your img tag. The format is: <img src="data:image/png;base64,iVBORw0KGgo..." alt="description">. The MIME type (image/png, image/jpeg, etc.) must match the original image format. The Base64 string can be very long for larger images, which makes the HTML harder to read, but it eliminates the need for an external image file. Some developers use this for dynamically generated images or when they need to keep everything in a single file.
Most common web image formats can be converted to Base64, including PNG, JPG/JPEG, GIF, SVG, and WebP. PNG and GIF support transparency. JPG is best for photographs. SVG is unique because it's already a text-based vector format, so encoding it to Base64 is optional—you can often embed SVG code directly. WebP is a modern format that offers good compression. The tool automatically detects the format and sets the correct MIME type in the data URI.
Use Base64 for small images like icons, logos, and UI elements where the 33% size increase is negligible and the reduced HTTP requests improve performance. Avoid it for large images like photographs where the size increase is significant and would slow page loads. Consider whether the image is used on multiple pages—Base64 images can't be browser-cached separately, so they're re-downloaded with each page. For most websites, a hybrid approach works best: Base64 for small, critical images and regular files for larger assets.
A data URI (Uniform Resource Identifier) is a URI scheme that allows embedding small files inline using the data: prefix. The format is data:[<mediatype>][;base64],<data>. The mediatype defaults to text/plain;charset=US-ASCII if omitted. For images, you specify the MIME type like image/png or image/svg+xml. The base64 keyword tells the browser to interpret the data as Base64 encoded. When the browser sees a data URI, it decodes the data and treats it as if it were loaded from an external file. This works in img tags, CSS, and JavaScript.
Related Tools
You might also find these utilities helpful for your image to base64 workflow.