Image to Base64 Converter
Convert any image to a Base64 data URI. Drag and drop or click to upload. Works with PNG, JPG, GIF, SVG, and WebP formats.
Last Updated: July 2026
100% Client-Side — Your data never leaves your device
Drop an image here, or click to browse
Supports PNG, JPG, GIF, SVG, WebP
Image to Base64 in Code
Convert images to Base64 data URIs programmatically.
JavaScript
// Browser: Convert File to Base64 data URI
function fileToBase64(file: File): Promise<string> {
return new Promise((resolve, reject) => {
const reader = new FileReader();
reader.onload = () => resolve(reader.result as string);
reader.onerror = reject;
reader.readAsDataURL(file);
});
}
// Node.js: Convert image file to Base64
import { readFileSync } from "fs";
const base64 = readFileSync("image.png").toString("base64");
const dataUri = `data:image/png;base64,${base64}`;Frequently Asked Questions
Search below or browse through our most commonly asked questions.
Drag and drop an image onto the upload area, or click to browse and select a file. The tool will instantly generate a Base64 data URI that you can copy and use in HTML, CSS, or JavaScript.
We support all common image formats: PNG, JPG/JPEG, GIF, SVG, WebP, and BMP. The MIME type is automatically detected from the file.
Since the conversion runs entirely in your browser, the limit depends on your device's memory. Typically, images up to 50MB work fine, but generating very large text strings can slow down the browser.