Base64 Encode for Data URIs — Inline Files in HTML
Quick Answer: Convert any file to a data URI by Base64-encoding it and prepending the MIME type. The result follows the format data:[mime];base64,[encoded-data] and can be used in src attributes or CSS url() values.
FAQ
What is a data URI?
A data URI embeds file content directly in HTML/CSS using the format data:[mime];base64,[data]. No separate file request is needed.
When should I use data URIs?
For small assets under 5KB like icons and simple SVGs. Larger files bloat the HTML and are better served as separate files with caching.