Ready to encode
Paste text/SVG or upload a file and click Generate// convert files & text to embeddable data URIs
Convert text, SVG, images, or any small file into a Base64 data URI for embedding directly in HTML, CSS, or JavaScript. Free, browser-based, instant.
Ready to encode
Paste text/SVG or upload a file and click GenerateSelect "Text / SVG" to paste code, or "File Upload" to drag and drop a file.
Pick the correct MIME type for your content, or let it auto-detect from the file extension.
Click Generate, then copy the data URI or select a ready-made snippet for HTML/CSS use.
A data URI (Uniform Resource Identifier) lets you embed file content directly inside HTML, CSS, or JavaScript as a Base64-encoded string. Instead of referencing an external file, the content travels inline with your code β eliminating an HTTP request and making assets self-contained.
A data URI is a URL scheme that encodes file content directly into the URI string using Base64. It starts with data:, followed by the MIME type, optional charset, the ;base64, marker, and then the encoded data.
Data URIs work best for small assets (icons, tiny images, fonts) where eliminating an HTTP round-trip matters more than the ~33% size overhead of Base64 encoding. Avoid them for large files β they inflate your HTML/CSS size and can't be cached separately by the browser.
Any file up to 2 MB β images (SVG, PNG, JPG, GIF, WebP), fonts (WOFF, WOFF2, TTF, OTF), stylesheets, scripts, JSON, XML, plain text, and more. The tool auto-detects the MIME type from the file extension.
File encoding happens entirely in your browser via the JavaScript FileReader API. Your files never leave your machine. The text/SVG mode uses a lightweight PHP endpoint, but no data is stored or logged.
Use it as a background-image value: background-image: url("data:image/svg+xml;base64,...");. The CSS Snippet tab generates this for you automatically.
Yes β SVG can technically be URL-encoded instead of Base64-encoded, but Base64 is more universally supported and easier to handle. This tool always outputs Base64 for maximum compatibility.
Base64 encoding increases file size by approximately 33%. This is the trade-off for inline embedding. Compress or optimize your file first (e.g. with our SVG Optimizer or Image Compressor) to keep the output manageable.
The MIME type tells the browser how to interpret the embedded data β whether it's an image, a stylesheet, a font, etc. Choosing the wrong MIME type will cause the browser to ignore or misrender the content.
A Data URI Generator is a developer tool that converts files, text, SVG markup, and other assets into Base64-encoded data URIs β self-contained strings you can embed directly inside HTML attributes, CSS properties, or JavaScript code. Instead of referencing an image or font via an external URL, you paste the entire encoded file inline, removing the dependency on an external HTTP request entirely.
This tool supports both text-based input (SVG, CSS, plain text, JSON, HTML) and binary file uploads (PNG, JPG, WebP, WOFF, TTF, and more), auto-detects the correct MIME type, and generates ready-to-paste code snippets for the most common embedding scenarios.
π‘ Looking for premium web development assets? MonsterONE offers unlimited downloads of HTML templates, UI kits, and front-end assets β worth checking out for your next project.
The data URI scheme is defined in RFC 2397 and follows this structure:
data:[<mediatype>][;charset=<charset>][;base64],<data>
image/png or image/svg+xmlWhen a browser encounters a data URI, it decodes the Base64 string back to binary and renders it as if it had fetched the file from a server. The difference: no network round-trip, no separate cache entry, no external dependency.
Data URIs shine in specific scenarios. Here's when they make sense:
Despite their usefulness, data URIs have real downsides:
SVG is a text format, which means it can technically be embedded as a URL-encoded string rather than Base64. However, Base64 SVG data URIs are more universally supported across browsers and tools, and this generator always outputs Base64 for consistency. For optimal SVG performance, run your SVG through an optimizer first to strip unnecessary metadata, comments, and whitespace before encoding.
Once you have your data URI, embedding it is straightforward. In HTML, use it as the src attribute of an <img> tag:
<img src="data:image/png;base64,iVBORw0KGgoAAAANS..." alt="Icon">
In CSS, use it as the value of a background-image:
.icon {
background-image: url("data:image/svg+xml;base64,PHN2Zy4uLg==");
background-size: contain;
}
For fonts, use it inside a @font-face rule:
@font-face {
font-family: 'MyFont';
src: url("data:font/woff2;base64,d09GMgAB...") format('woff2');
}
This tool generates all three snippet types automatically β just switch the tab after encoding your file.
An alternative to data URIs for JavaScript-based workflows is the Blob URL (URL.createObjectURL()). Blob URLs are shorter (they're just a reference to an in-memory object) and can represent any file size without the Base64 overhead. However, they are session-only β they expire when the page is closed, making them unsuitable for persistent storage in HTML or CSS. Data URIs are the right choice when you need a string you can save, copy, and paste into source code.
Most modern browsers support data URIs of arbitrary length, though older versions of Internet Explorer had a 32 KB limit. As a practical guideline, keep data URIs under 32 KB to ensure broad compatibility and performance. This generator enforces a 2 MB file upload limit, which outputs a ~2.7 MB data URI β well above what you'd typically want to inline, but useful for testing and edge cases.