画像からBase64
Convert any image to a Base64 encoded data URI for embedding in HTML or CSS.
Image Upload
Click or drag an image file here
1 image · Max 2MB
Base64 Result
Image to Base64
This tool converts an image file into a Base64 encoded data URI string. You can embed this string directly in HTML or CSS, eliminating the need for a separate image file request.
Base64 encoding increases the data size by approximately 33%, so it's best used for small images like icons and logos rather than large photographs.
How to use
- Drag and drop an image file onto the upload area, or click to select.
- The Base64 encoded data URI appears in the text editor below.
- Use Copy to copy the result or Save to download as a text file.
Embedding images in HTML
You can use Base64 data URIs directly in HTML img tags:
<img src="data:image/png;base64,ivborw0kggo..." width="300" height="100" alt="base64 image"/>
/* In CSS */
.logo {
background: url('data:image/png;base64,ivborw0kggo...');
}
Convert with Python
Convert an image to Base64 using Python:
import base64
with open('image.png', 'rb') as f:
encoded = base64.b64encode(f.read())
data_uri = 'data:image/png;base64,' + encoded.decode()