File to Data URL Creator
Convert any file to a Base64 Data URL, encode text as a data URI, or decode a Data URL back to a downloadable file. 100% client-side.
Drag & drop a file here
or browse to select — any file type
How to Use the Data URL Creator
- File to Data URL — drag and drop any file to instantly generate its Base64 Data URL. Images are previewed inline. The size comparison shows the original vs encoded size.
- Text to Data URL — enter any text (HTML, SVG, CSS, JSON) and select a MIME type. The Data URL updates live. Toggle Base64 encoding for binary-safe output.
- Data URL to File — paste any Data URL to decode it. Images are previewed; all file types can be downloaded back as the original file.
What Is a Data URL?
A Data URL (or data URI) is defined in RFC 2397. It embeds file content directly in a URL string using this format:
data:[<mediatype>][;base64],<data>
For example, a small red pixel PNG might look like: data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8/5+hHgAHggJ/PchI6QAAAABJRU5ErkJggg==
Data URLs are supported in all modern browsers in HTML <img> tags, CSS background-image properties, <script> and <link> tags, and anywhere a URL is accepted. They bypass the browser's HTTP cache (since the data is inline) and eliminate a network round-trip, which is beneficial for very small files.
When to Use Data URLs
Data URLs work best for small, frequently reused assets where eliminating an HTTP request outweighs the 33% size overhead:
- Small icons and favicons — embed a 1 KB icon directly in your HTML or CSS
- Loading spinners — avoid a request for a tiny GIF or SVG animation
- Email HTML — many email clients block external images; embedded Data URLs always display
- CSS background images — patterns and gradients under 5 KB
- Inline SVGs in CSS — complex vector icons that change color via CSS filter
- Auto-generated reports — self-contained HTML files with all assets embedded
When Not to Use Data URLs
Avoid Data URLs for:
- Large images — a 500 KB photo becomes 667 KB of text and cannot be cached separately
- Files used on multiple pages — a separately cached asset file loads once; a Data URL re-transmits every page load
- Resources that change frequently — cache invalidation is harder since the URL contains the content
SVG Data URLs
SVG files can be used as Data URLs without Base64 encoding. A plain text SVG can use URL encoding: data:image/svg+xml,%3Csvg...%3E. This is often smaller than the Base64 equivalent. The Text mode in this tool generates both formats. For related tools, see the Base64 Encoder/Decoder and File Checksum Verifier.