Boneyard Tools

Data URI Generator

Paste text, SVG or HTML and get a data: URI you can drop straight into CSS or HTML. Choose base64 for arbitrary content, or compact URL encoding that keeps SVG small and readable. Everything runs in your browser.

How to make a data URI

  1. Paste your content and set the MIME type (for example image/svg+xml).
  2. Choose URL encoding for SVG or base64 for other content.
  3. Copy the data URI, or the ready-made CSS background or HTML img snippet.

Examples

Plain text as a data URI

Hello
data:text/plain;base64,SGVsbG8=

SVG with compact URL encoding

<svg xmlns="http://www.w3.org/2000/svg" width="2" height="2"></svg>
data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='2' height='2'%3E%3C/svg%3E

Frequently asked questions

What is a data URI?

A data URI embeds a file directly inside a URL using the data: scheme, so the content travels inline instead of being fetched separately. It looks like data:<mime>;base64,<data> or data:<mime>,<url-encoded>, and works anywhere a URL does, such as a CSS background-image or an HTML img src.

When should I use a data URI?

They are best for small, static assets like icons, SVG shapes, fonts or tiny images. Inlining them removes an extra HTTP request, which helps above-the-fold rendering and self-contained emails or single-file pages. For large or frequently changing files a normal URL is better, because data URIs are not cached on their own and the base64 form adds about a third to the byte size.

Should I use base64 or URL encoding?

Use URL encoding for SVG and other text-based markup. It is usually smaller than base64 and stays human-readable, so you can still read the markup inside the URI. Use base64 for binary or arbitrary content where readability does not matter.

How is the SVG URL encoding done?

Rather than escaping everything with encodeURIComponent, which roughly doubles the size, this tool escapes only the characters that would break the URI: % # < and >. Double quotes are swapped for single quotes (valid in SVG) so the result can sit inside a double-quoted CSS url() or HTML attribute, and runs of whitespace are collapsed. The SVG renders identically but stays compact and readable.

Does it handle emoji and accented text?

Yes. Base64 output is UTF-8 safe, so emoji, accents and other multi-byte characters are encoded correctly and decode back to the exact original.

Is my content private?

Yes. The data URI is generated entirely in your browser, so nothing you paste is uploaded or stored on a server.

Related tools