Image to Base64 Converter
Convert an image file to a Base64-encoded data URI you can paste straight into CSS, HTML or JSON. Drag and drop or browse, then copy the raw Base64 string or the full data: URI. Nothing is uploaded anywhere.
Drop an image or click to browse. The file is read locally and converted to Base64 in your browser — copy the raw string for an API payload, or the full data: URI to drop directly into a src or background-image.
Image
Drop an image here, or click to browse
PNG, JPG, SVG, WebP, GIF — stays on your device
Learn more
What Base64 encoding does for images
Base64 encoding converts binary image data into a text string using a 64-character alphabet, making it safe to embed in formats that only support text — HTML, CSS, JSON, XML, and email. The encoding is purely a transport mechanism: it adds no compression, no encryption, and no transformation of the image data itself. The decoded bytes are bit-for-bit identical to the original file; the ~33% size increase is simply the cost of representing 8-bit binary data as 6-bit ASCII characters.
For images specifically, Base64 solves the problem of inline embedding. Instead of referencing an external file with <img src="icon.png">, the entire image travels as text within the HTML: <img src="data:image/png;base64,iVBOR...">. This eliminates a separate HTTP request for the image, which matters most for small assets where the request overhead exceeds the transfer time.
The data URL format
A data URL (defined in RFC 2397) is the wrapper that makes a Base64 string usable as an image source. Its structure is data:[<media type>][;base64],<data>. The media type — image/png, image/jpeg, image/svg+xml, image/webp — tells the browser how to interpret the decoded bytes. The ;base64 marker indicates the data is Base64-encoded rather than URL-encoded. Without the ;base64 marker, the data is assumed to be URL-encoded text, which is appropriate for small text-based formats like SVG but wrong for binary formats like PNG.
The media type is not just a label — it determines how the browser handles the data. A data URL with image/svg+xml will be parsed as XML and can be styled with CSS; one with image/png is treated as a raster image and cannot be manipulated. Omitting the media type defaults to text/plain, which means the browser will display the Base64 string as text rather than rendering it as an image.
When to embed vs. use separate files
Embedding makes sense for small, frequently used images where the HTTP request overhead dominates: icons, tiny thumbnails, single-use images in email, and CSS background images that would otherwise require extra requests. The performance calculus is simple: if the image is under ~1 KB and appears on every page, embedding it saves a round-trip; if it's over ~10 KB, the 33% Base64 overhead usually exceeds the savings from avoiding the request, and a separate file with proper cache headers is more efficient.
Separate files win for large images, images shared across many pages (where browser caching amortizes the download cost), and images that change independently of the HTML that references them. Embedded images cannot be cached separately — they're re-downloaded every time the HTML or CSS file changes. A 50 KB image embedded in a CSS file means every CSS cache invalidation re-downloads all 50 KB (plus 33% overhead), whereas a separate file is fetched once and cached indefinitely.
Email embedding and CSS data URLs
Email is the original and still most demanding use case for Base64 image embedding. Email systems were designed for plain-text MIME messages, and while modern email clients support HTML, the attachment mechanism varies wildly across clients. Embedding images as Base64 data URLs within the HTML body ensures the image travels with the message and renders inline regardless of the recipient's email client — at the cost of inflating the message size and preventing the client from caching the image.
In CSS, data URLs let you embed small background images directly in a stylesheet: background-image: url("data:image/svg+xml;base64,..."). This is common for icon systems and UI elements that need to render before external images load. SVG is particularly well-suited for CSS embedding because it's already text — URL-encoded SVG can be embedded without Base64, though Base64 is often simpler to generate and avoids escaping issues with quotes and special characters.
Performance implications and browser compatibility
The performance cost of Base64 embedding is threefold: the ~33% size increase, the CPU cost of decoding Base64 back to binary at render time, and the loss of independent caching. For small images these costs are negligible; for large ones they compound. Modern browsers decode Base64 efficiently, but the decoded bytes still must be parsed as an image format — a 5 MB PNG embedded as Base64 is still a 5 MB image the browser must decode, now with 6.7 MB of text transfer and Base64 decoding overhead on top.
Browser support is universal — every browser that supports images supports data URLs, and there are no compatibility concerns with the format itself. The practical limits are context-dependent: some email clients strip or block data URLs entirely (Outlook.com has historically done so), and very large data URLs can hit URL length limits in older browsers. The guidance is consistent: use Base64 embedding for small, critical images where the request overhead or delivery mechanism justifies the overhead, and use separate files with proper cache headers for everything else.
Frequently asked questions
Is my image uploaded to a server?
No — the file is read and encoded entirely in your browser using the File and FileReader APIs. It never leaves your device.
What's the difference between the raw Base64 and the data URI?
The data URI (data:image/png;base64,...) is ready to drop straight into an HTML src or CSS background-image. The raw Base64 string is the same payload without that prefix, for when you need to build the URI yourself.
Why is the encoded result bigger than my original file?
Base64 always adds roughly 33% overhead versus the raw binary — expected for any Base64-encoded payload, not specific to images.
Want the background? Read the guide: What is Base64?