data:image/;base64,... URL, ready to paste into HTML src, CSS url(), or JSON. Use it for inline icons under 4 KB, email templates that demand inline assets, and small SVGs that don’t justify a network request. Our free image-to-Base64 converter runs entirely in your browser — drag and drop any image, copy the result.A Base64 data URL inlines an image directly into HTML, CSS, or JSON. Instead of <img src="logo.png"> with a network request, you write <img src="data:image/png;base64,iVBORw0KGgo..."> and the image is part of the document. That eliminates the round-trip — useful for tiny icons in critical CSS, email templates that demand inline assets (Gmail blocks externally-hosted images by default), and JSON payloads where a separate file isn’t an option (push notifications, web push payloads, embedded widget configs).
Our image to Base64 converter handles every common format, runs in your browser (the file never uploads), and gives you four output shapes — raw Base64, full data URL, CSS url(), and HTML <img> tag. This guide covers when inlining is the right call (often it isn’t), the size overhead (~33%), and the gotchas with caching, gzip, and font-icon migration.
When to inline an image as Base64 — and when not to
| Use case | Inline as Base64? | Why |
|---|---|---|
| Icon under 4 KB in critical CSS | Yes | Saves a request on the critical path |
| HTML email template | Yes (often required) | Most clients block external images by default |
| Large hero image (> 50 KB) | No | Inflates HTML, blocks parsing, no CDN caching |
| Image used on every page | No | External file caches once, serves N times |
| SVG icon set used 5+ times per page | Maybe — try SVG sprite first | Sprite sheets compress better than per-icon Base64 |
| Embed widget configuration JSON | Yes | JSON can’t reference external files |
| Push notification icon | Yes | Browser push payloads are limited and need self-contained data |
The 33% size penalty
Base64 encodes 3 raw bytes as 4 ASCII characters. That’s a 33% size overhead before any other effects. A 12 KB PNG becomes a ~16 KB Base64 string. For text-mode HTTP responses (HTML, CSS, JSON), gzip compresses the Base64 string back down — typically to within 5–8% of the original binary size. So the true overhead in a gzipped HTTP response is small.
What gzip can’t fix: Base64-inlined assets are part of the HTML, so they block the HTML parser longer. They can’t be cached separately by the browser — every page load redownloads the whole HTML including the inline image. For an icon shown on every page, this trades a one-time round-trip for a recurring kilobyte penalty. Run the math.
How to convert an image to Base64
- Open the image to Base64 converter
- Drop your image, click to pick a file, or paste from clipboard
- The converter detects the MIME type automatically (
image/png,image/jpeg,image/svg+xml, etc.) - Pick output format: Raw Base64, Data URL, CSS url(), or HTML <img> tag
- Click Copy — paste into your HTML, CSS, or JSON
Output shapes — paste-ready for every context
The same image produces four different output strings depending on where you’ll paste it:
// Raw Base64
iVBORw0KGgoAAAANSUhEUgAA...
// Data URL — works in HTML src, CSS url(), JS Image()
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA...
// CSS url()
.icon { background: url("data:image/png;base64,iVBORw...") no-repeat; }
// HTML img tag
<img src="data:image/png;base64,iVBORw0KGgo..." alt="...">
Common gotchas
- SVGs can be inlined more efficiently as URL-encoded SVG. Instead of
data:image/svg+xml;base64,...usedata:image/svg+xml;utf8,...with URL-encoded SVG markup. The result is smaller (no Base64 overhead) and gzip-compresses better. Most modern browsers support both forms. - Don’t inline JPEGs above ~10 KB. The Base64 string bloats your HTML by 33%, blocks the parser, and the savings from one fewer request are negligible compared to the parsing cost. Use a CDN.
- Gmail strips inline Base64 PNGs above 4 KB in some cases. Email-client behaviour varies wildly; test with Litmus or Email on Acid before mass-mailing a campaign that depends on inline images.
- CSP headers may block data URLs. A Content Security Policy with
img-src: 'self'blocksdata:URLs. Adddata:toimg-srcif you use inline images:img-src 'self' data:;. - Don’t inline animated GIFs as Base64. Encoded GIF blobs are huge (often 100 KB+ for a 5-second clip), and most email clients render the first frame only anyway. Use a hosted MP4 or animated WebP for non-email contexts.
- Build pipelines do this automatically. Webpack’s
asset/inline, Vite’s?inlineimport suffix, and Next.js’snext/imageall auto-inline assets below a threshold. For a real codebase, configure that threshold in your bundler instead of running this tool by hand.
When NOT to use this tool
If your build pipeline (Webpack, Vite, Parcel, Next.js, Astro) handles inlining automatically — set the threshold in your bundler config and trust it. For batch automation in CI, write a Node script that reads the image and outputs the data URL — no browser needed. For SVG-heavy use, prefer SVG sprite sheets or inline <svg> markup over data URLs — they compress better and remain editable. Use this browser tool for one-off conversions, email templates pasted into Mailchimp/SendGrid, embed-widget config files, and learning what a data URL looks like.
Frequently asked questions
What’s the file size limit?
Effectively your browser’s available memory. Conversion is fast for files up to several MB. Above 10 MB the Base64 string itself becomes unwieldy to paste. There’s no point inlining an image that large — use a CDN.
Why does my Base64 string differ between tools?
Same input bytes always produce the same Base64. Differences come from MIME type detection, line-break formatting (some tools insert \n every 76 characters per RFC 2045; modern tools output unbroken strings), or trailing padding. The encoded image bytes are byte-identical.
Will inlining help my page load faster?
For tiny critical-path images (under 4 KB, used once), yes — saves a network round-trip. For images used on multiple pages or above 10 KB, no — you bloat HTML with no caching, which is usually worse than a single fetch. Test with Lighthouse before committing.
Does this work for SVGs?
Yes, but a URL-encoded SVG (data:image/svg+xml;utf8,...) is usually smaller than Base64. Our converter offers both forms — pick “URL-encoded” for SVGs to save a few bytes.
Is my image uploaded?
No. The converter runs in your browser using the FileReader API. The image is loaded into memory and encoded locally — it never leaves your device. You can verify in the Network tab: dropping a file produces zero outbound requests.
Can I decode Base64 back to an image?
Yes — paste a data URL into the converter and toggle “Decode mode”. The original image is reconstructed and offered as a download. Useful for inspecting an inlined asset you want to extract from a page.
Related tools and guides
- Image to Base64 Converter
- Base64 Encoder/Decoder (text)
- Image Resizer
- SVG to PNG Converter
- All image tools
