Image to Base64
Convert images to base64 data URIs for embedding directly in HTML, CSS, or JSON. Eliminate HTTP requests for small images.
Drag & drop an image here or browse
Supports: JPG, PNG, GIF, WebP, SVG, ICOHow to Use Image to Base64
How to Convert Images to Base64
- Upload image: Select a JPEG, PNG, GIF, WebP, or SVG file.
- Wait for encoding: The image is converted instantly in your browser.
- Choose output format: Select Data URI, raw Base64, CSS, or HTML output.
- Copy result: Copy the encoded string to your clipboard.
- Paste in code: Use directly in your HTML, CSS, or JavaScript.
Example Outputs
HTML img tag:
<img src="data:image/png;base64,iVBORw0KGgo..." alt="Embedded image">
CSS background:
.icon { background-image: url(data:image/png;base64,iVBORw0KGgo...); }Features
- Convert JPEG, PNG, GIF, WebP, SVG to Base64
- Generate complete Data URI
- Output as HTML img tag
- Output as CSS background-image
- Raw Base64 string option
- Show original file size
- Show Base64 string size
- One-click copy to clipboard
- Preview embedded image
- Client-side processing (no upload)
- No file size limit
- Free with no registration
About Image to Base64
Every image on a webpage typically requires a separate HTTP request. For small images, the request overhead exceeds the image size itself. Base64 encoding embeds images directly in HTML or CSS, eliminating these requests and potentially improving performance.
How Base64 Encoding Works
Base64 converts binary image data to ASCII text:
- Encoding: Binary bytes mapped to 64 printable characters
- Size increase: Encoded data is ~33% larger than original binary
- Data URI format: data:image/png;base64,iVBORw0KGgo...
- Browser support: Universal across modern browsers
When to Use Base64 Images
Ideal for: Icons under 2KB, CSS background patterns, single-use images, email HTML templates. Avoid for: Large photos, images used across multiple pages (lose caching benefit), frequently changing images.
Performance Considerations
While base64 eliminates HTTP requests, it increases HTML/CSS file size by 33%. The encoded data also can't be cached separately from the document. For images under ~2KB, the request savings outweigh the size increase. Larger images should remain separate files.
Integration in Development
Use base64 encoding for: embedding critical icons in initial HTML, including images in single-file exports, creating self-contained email templates, and reducing complexity in projects without build tools.