Tools

Home
Base64 Encode/DecodeString to HexHash GeneratorUTF-8 Encode/DecodeURL Encode/Decode

Convert Image To Data Uri Online

Convert Image To Data Uri online. All processing happens in your browser.

Your files never leave your browser
No image loaded
INPUT
🖼

Drop image here or click to upload

Max 50MB • 100% Private

OUTPUT
Ready

Drop a PNG, JPG, SVG, or WebP and get back a ready-to-paste data:image/...;base64,... string. The MIME prefix is detected for you, so you can drop it straight into an <img> tag, a CSS url(), or an HTML email without fixing paths.

And everything runs in your browser. Nothing gets uploaded.

How It Works

Drop Image File
→
Base64 Encode via Canvas
→
Copy Data URI String

Your browser reads the image file with a FileReader, draws it onto an invisible HTML canvas, then calls toDataURL() to get the Base64-encoded string. The result includes the full data URI prefix (data:image/png;base64,...) so you can paste it straight into an <img> tag or CSS background property. No server round-trip involved.

Examples

Embedding a favicon in an HTML email

Email clients block external images by default. Inline data URIs render immediately without the "show images" prompt.

INPUT
logo.png (16x16, 1.2 KB)
OUTPUT
data:image/png;base64,iVBORw0KGgo... (~1,600 characters)

CSS background for a loading spinner

A small spinner GIF as a data URI means zero extra network requests. It shows up the instant the CSS loads — no flash of missing image.

INPUT
spinner.gif (24x24, 3.8 KB)
OUTPUT
background: url(data:image/gif;base64,R0lGODlh...) ~5,100 chars in your stylesheet

Single-file HTML report with embedded charts

You need to send a standalone report that someone can open without a web server or folder of assets. Convert each chart screenshot to a data URI and drop them into the HTML. One file, everything included.

INPUT
chart-q1-revenue.png (600x400, 45 KB)
OUTPUT
data:image/png;base64,iVBOR... ~61,400 chars (Base64 is ~33% larger than the original binary)

Who Uses This

👨‍💻 Frontend Developers

Inline small icons and sprites directly into CSS to cut HTTP requests on performance-critical pages.

📧 Email Developers

Embed logos and UI elements so they render in email clients that block remote images by default.

📊 Data Analysts

Package chart images inside single-file HTML reports that colleagues can open without a server.

🎨 Designers

Quick-test how an image looks embedded in a prototype without setting up asset hosting.

Common Mistakes

Encoding large photos as data URIs

A 500 KB JPEG becomes roughly 667 KB of Base64 text. That bloats your HTML or CSS file and can't be cached separately by the browser. Stick to images under 10–15 KB for real performance gains — anything bigger is better served as a regular file.

Forgetting the MIME type matters

If you manually paste a data URI and change image/png to image/jpeg (or vice versa) without actually re-encoding, the browser will either show a broken image or silently render garbage. This tool detects the format automatically — don't hand-edit the prefix.

Using data URIs for images that repeat across pages

A normal image file gets cached once and reused on every page load. A data URI baked into CSS or HTML gets downloaded fresh every single time. If the same icon appears on 20 pages, serve it as a file instead.

Technical Details

Frequently Asked Questions

What is a data URI?

It's a way to embed file data directly inside a URL string. Instead of pointing to an external file like src="logo.png", the image bytes are Base64-encoded and stuffed into the URL itself: src="data:image/png;base64,...". The browser decodes it on the spot — no extra HTTP request needed.

Does converting to Base64 increase file size?

Yes. Base64 encoding adds about 33% to the original file size because it represents binary data using only ASCII characters. A 30 KB image turns into roughly 40 KB of text. That's fine for small icons but adds up fast with larger images.

When should I use data URIs instead of regular image files?

Best for small images under 10–15 KB — think icons, tiny logos, or UI sprites. Also great when you need a single self-contained HTML file with no external dependencies. For anything larger, a regular image file with proper caching will perform better.

Can I use a data URI in CSS?

Absolutely. Just paste the full string inside url() in your CSS: background-image: url(data:image/png;base64,...);. Works in every modern browser. It is probably the most common use case — developers inline small background textures and icons this way all the time.

Is my image uploaded to a server?

No. The conversion happens entirely in your browser using JavaScript's FileReader and Canvas APIs. Your image data never leaves your machine. You can disconnect from the internet after loading the page and it'll still work.

Share: