About the Data URI Generator
This tool converts a file or pasted text into a data: URI you can paste into HTML or CSS. You can pick Base64 encoding for binary files like PNG, JPG, or fonts, or use URL percent encoding for text and SVG. The page gives ready to paste snippets for img src, CSS background, and @font-face rules, plus the output size and encoding overhead. Everything runs in your browser, so the file never uploads to a server. The generator follows the data URL syntax in RFC 2397 and uses Base64 rules per RFC 4648 when you choose that option. Use it for very small assets, inline SVGs, tiny icons, or single-use font rules. Avoid embedding large images because Base64 typically increases payload size by about 33 percent.
How to use it
- 1Choose a file or paste text into the input field.
- 2Select the MIME type and pick Base64 or URL percent encoding.
- 3Preview the result and check the reported size and overhead.
- 4Copy the ready HTML or CSS snippet or download the encoded output.
Worked example
Worked example 1: Input a 10,000 byte PNG. Base64 output length = 4 * ceil(10000 / 3) = 13,336 characters, about 13.3 KB. Worked example 2: Text input "Hi" becomes: data:text/plain,Hi
How it works
Turns a file or text into a data: URI (Base64 or URL encoded) with ready-to-paste HTML and CSS snippets and the sizeWorks in the browser with nothing to installSource: RFC 2397 data URL schemeRFC 4648 Base64 encodingMDN Web Docs: data: URLs. Last checked 5 November 2026.
What it is good for
- Runs entirely in your browser; files do not upload.
- Produces ready HTML and CSS snippets you can paste.
- Shows output size and Base64 overhead so you can judge tradeoffs.
- Not suitable for large files; Base64 commonly increases size by about 33 percent.
- Some email clients and strict CSP policies block data: URIs; test before mass use.
Questions people ask
What is a data URI and how is it formed?
A data URI embeds data directly in the URI using the syntax data:[mediatype][;base64],<data>. The formal syntax is specified in RFC 2397.
When should I choose Base64 versus URL percent encoding?
Use Base64 for binary files like PNG, JPG, and fonts. Use percent encoding for text and SVG when you want smaller, readable output.
How much larger does Base64 make the payload?
Base64 increases payload size by roughly 33 percent because it encodes three bytes as four characters. RFC 4648 defines the exact rules.
Does this tool upload my files to a server?
No. The generator runs in your browser and performs encoding locally, so files are not uploaded to our servers.
Will a data URI work inside email?
Support is inconsistent. Many modern clients render data: images, but some clients, including some versions of Outlook, may block them. Always test the target clients.
Can I decode a data URI back to a file?
Yes. You can paste a data URI into a decoder or programmatically base64 decode the payload and save the bytes as a file.
Help keep every tool free
FreeToolr stays free because people help it grow. Share a tool you like, tell us what to build next, or support us on Ko-fi.