Select File
drag & drop an image, SVG, or font file here
Convert Image To Base64 Code
Data URI Generator converts image files into Base64 encoded strings that can be directly used inside HTML and CSS. Small Data URIs can be pasted directly into stylesheets generated by our CSS Background Generator.
Instead of loading a separate image file, developers can embed small assets directly into code.
What Is Data URI?
A Data URI represents a file as text. It can be used directly inside a CSS background-image or an HTML img src attribute.
Common Uses
Developers use Data URI for:
- Small icons
- CSS backgrounds
- Email templates
- UI assets
Benefits include reduced HTTP requests and easy asset embedding.
When Not To Use Data URI
Avoid using it for large images, photos, or hero images. Large Base64 strings increase page size and block CSS parsing.
How It Works
- Upload image
- Convert to Base64
- Copy generated code
Common Problems This Tool Solves
- A tiny 1KB loading spinner icon requires an entirely separate HTTP request.
- HTML email templates break because external images are blocked by email clients.
- Webpack or Vite bundlers fail to inline small assets correctly.
When Should You Use This Tool?
- When embedding tiny icons or loading spinners directly into a CSS file.
- When building HTML email templates where external images are frowned upon.
- When creating a single-file portable HTML document with zero external dependencies.