Image to data URI, HTML and CSS
- Free
- No sign-up
- No upload
- Works offline
Tool facts
- Opens
JPGPNGWEBPAVIFGIFBMPSVGICO- Saves as
TXT- Price
- Free, no sign-up, no watermark
- Are files uploaded?
- No. Everything is processed in this browser, on your device.
- Batch processing
- One file at a time
- Offline use
- Works without a connection once this page has loaded
- Browser
- A recent Chrome, Edge, Firefox or Safari, on computer or phone.
- Limits
- No fixed file size limit; very large files depend on your device's memory and may fail on phones.
Check it yourself: press F12, open the Network tab, then use the tool. No request carries your data.
About Image to Base64
Image to Base64 encodes a picture as a data URI — a text string that starts with data:image/png;base64, followed by the file's bytes in Base64 — so you can embed it directly in HTML, CSS, JSON, an email template or source code without hosting a separate file. Drop an image and you instantly get four outputs: the full data URI, the bare Base64 string, an HTML img tag with width and height, and a CSS background-image rule.
Base64 makes data about 33% larger than the original binary file, so it is best for small icons, logos and placeholders under a few kilobytes, where saving an extra HTTP request matters more than size. For SVG files the tool can instead produce a URL-encoded data URI, which is usually smaller than Base64 and stays readable. The file is read locally with the FileReader API and is never uploaded; the original bytes are encoded unchanged, so there is no recompression or quality loss.
Image to Base64 runs entirely in your browser. Your data is processed on your device and is never uploaded to Qiyi or anyone else.
How to use Image to Base64
- Drop an image onto the page, click to choose one, or paste an image with Ctrl V.
- Check the preview and the size statistics: file size, data URI length and overhead.
- For SVG files, optionally turn on URL-encode SVG for a shorter data URI.
- Click Copy next to Data URI, Base64 only, HTML img tag or CSS background, or download the data URI as a .txt file.
Frequently asked questions
Is my image uploaded?
No. The file is read with your browser's FileReader API and encoded on your device. Nothing is sent to a server.
Why is the Base64 string bigger than my image?
Base64 represents every 3 bytes with 4 text characters, so the encoded data is about 33% larger than the file, plus the short data:image/…;base64, prefix. Gzip or Brotli compression on your server recovers part of that overhead in HTML and CSS files.
When should I embed images as Base64?
For tiny images such as icons, logos, loading spinners and placeholders (roughly under 5–10 KB), or when a single self-contained file is required, like an HTML email or an offline page. Large images are better served as separate files because they can be cached on their own and don't block the HTML or CSS from loading.
What is the difference between a data URI and Base64?
Base64 is only the encoded text. A data URI adds the scheme and MIME type in front, for example data:image/png;base64,iVBORw0…, which is what browsers need in src and url() attributes. Use the Base64 only output for APIs or JSON fields that expect raw Base64.
Do Base64 images work in emails?
Apple Mail and many mobile clients show them, but Gmail and several versions of Outlook block data URI images. For newsletters, attach the image or host it instead.