Generate data URIs from any file for inline HTML/CSS embedding. Supports images, PDFs, fonts, and more. Includes MIME type detection. 100% client-side.
Drag & drop files here
or click to browse. Select multiple files at once. (max 50 MB each)
A data URI embeds file content directly in an HTML attribute or CSS property, replacing an external URL with the file data itself. This tool generates data URIs from any file by reading it locally, detecting its MIME type, and encoding the content as Base64. For all Base64 tools and reference material, visit the Base64 Hub.
Every data URI follows this structure:
data:[<mediatype>][;base64],<data>
image/png, application/pdf, audio/mpeg). Defaults to text/plain;charset=US-ASCII if omitted.Examples:
data:image/png;base64,iVBORw0KGgoAAAANSU...
data:text/html,%3Chtml%3E%3Cbody%3EHello%3C/body%3E%3C/html%3E
data:text/plain;charset=utf-8,Hello%20World
<img src="data:image/png;base64,iVBORw0KGgo..." alt="Inline image" />
.icon {
background-image: url(data:image/svg+xml;base64,PHN2Zy...);
}
<a href="data:application/pdf;base64,JVBERi..." download="document.pdf">
Download PDF
</a>
<link rel="icon" href="data:image/svg+xml;base64,PHN2Zy..." />
<iframe src="data:text/html;base64,PCFET0NUWVBF..." width="100%" height="400"></iframe>
const audio = new Audio('data:audio/mpeg;base64,SUQz...');
const img = new Image();
img.src = 'data:image/png;base64,iVBOR...';
| Aspect | Data URI | External URL |
|---|---|---|
| HTTP requests | None | One per resource |
| Caching | Cannot cache independently | Cached by browser |
| Size overhead | +33% (Base64) | None |
| First load | Faster for small files | Faster for large files |
| Repeat visits | Re-downloaded with parent | Served from cache |
| CSP compatibility | Requires data: source | Works by default |
| Gzip efficiency | Poor (high entropy) | Good (raw binary) |
Content Security Policy (CSP) can restrict data URIs. A strict CSP without data: in the source list blocks data URIs:
Content-Security-Policy: img-src 'self'; /* blocks data: images */
Content-Security-Policy: img-src 'self' data:; /* allows data: images */
If your application uses CSP, ensure the relevant directives (img-src, font-src, media-src, style-src) include data: if you use data URIs. Be aware that allowing data: in script-src is generally considered unsafe, as it enables inline script injection.
Data URIs were standardized in RFC 2397 (1998). The scheme was designed for including small data items inline in web documents, avoiding the overhead of separate HTTP transactions. Despite being nearly 30 years old, the specification remains unchanged and universally supported.
| Resource type | Recommended max for data URI |
|---|---|
| Favicon | 10 KB |
| CSS icon / sprite | 5 KB |
| Small UI image | 10 KB |
| Font subset | 20 KB |
| Audio clip | 100 KB |
| Any other file | 10 KB (unless single file export) |
Above these thresholds, separate files with HTTP caching deliver better overall performance.
For specific file types, see Image to Base64, PDF to Base64, Audio to Base64, or the CSS Background Image generator.
Nothing you paste leaves this tab. Every tool runs entirely in your browser — no upload, no server, no account.