Base64 Image Encoder
Convert any image to a Base64 string or Data URI instantly. Supports PNG, JPG, GIF, SVG, WebP and more. Get ready-to-use code snippets for HTML, CSS, and JSON — 100% in your browser, nothing uploaded.
What is a Base64 Image Encoder?
A Base64 image encoder converts binary image data (PNG, JPG, GIF, SVG, etc.) into a string of printable ASCII characters. The result — called a Data URI — lets you embed images directly into HTML, CSS, JSON, or any text-based format without needing a separate image file or HTTP request.
A typical Data URI looks like: data:image/png;base64,iVBORw0KGgo.... The browser can render this exactly like a regular image URL — it just reads the embedded data directly from the string.
Output Formats Explained
Data URI
The full Data URI string including the MIME type prefix. This is the most universally useful format and can be pasted directly into an src attribute or CSS url().
HTML <img> tag
A complete, ready-to-paste <img> element with the Base64 data URI as the src. Drop it into any HTML file and the image renders immediately — no external file needed.
CSS background-image
A CSS background-image property using the Data URI. Useful for embedding small icons or textures directly in your stylesheet.
JSON value
The raw Base64 string (without the Data URI prefix) formatted as a JSON string value. Use this when transmitting images in API payloads or configuration files.
When NOT to use Base64 Images
- Large images — Base64 adds ~33% size overhead. Embedding a 500 KB photo adds ~665 KB to your HTML file, blocking the entire page parse.
- Images used on multiple pages — a regular image URL can be cached by the browser; a Base64 string embedded in HTML cannot be cached separately.
- SEO-critical images — search engines may not index Base64-embedded images as effectively as externally hosted ones.
Frequently Asked Questions
url() function. Select the "CSS background" output tab in this tool to get the ready-to-use property. You can then add background-size, background-repeat, and other properties as needed. This technique is especially popular for small UI icons to avoid extra HTTP requests.