Image to Base64
New
Encode PNG, JPG, SVG, or WebP icons into copy-ready Base64 strings, HTML img tags, or CSS data URIs locally in your browser with size warnings.
or drop your image file here
Runs in your browser — your file never leaves your device.
Working…
Processing your file…
Your file is ready.
Encode any image as a Base64 string or a full data URI — the format you need to inline a picture in HTML, CSS or a JSON payload. The encoding happens in your browser, and the result downloads as a text file along with its size, so you can judge whether inlining is worth it.
How to use Image to Base64
- Choose the image (JPG, PNG, WebP, GIF all work).
- Pick the output: full data URI for HTML/CSS, or raw Base64 only.
- Click "Encode Image" and download the .txt — or copy the preview.
Who it is for
For developers inlining small images into HTML emails, CSS backgrounds or single-file builds, and for anyone moving an image through an API that speaks Base64.
How it works
- The file’s bytes are encoded directly — no re-encoding, no quality change.
- The data URI includes the correct MIME type from the file.
- Large images are encoded in chunks to avoid memory limits.
What it cannot do
- Base64 grows a file by about a third — inline only small images.
- Email clients trim data URIs aggressively; test the target before committing.
Sample input & output
Upload a 1.4 KB SVG checkmark icon (check.svg) with "Full data URI" selected
data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCI+... — ready for <img src="..."> or CSS background-image: url("...").
Frequently asked questions
What is a Base64 data URI?
The whole image encoded as text: data:image/png;base64,… — a browser renders it exactly like the file, without any separate request.
When should I inline an image instead of linking it?
For small icons and logos in HTML emails or single-file builds. Large images inline poorly — the text file grows by about a third.
Does Base64 encoding change my image?
Never. The bytes are encoded one-to-one; decode them and you get the identical file back.
Why does Base64 encoding increase image byte size by roughly 33%?
Base64 slices binary input into 24-bit groups (three 8-bit bytes) and maps each 6-bit chunk onto one of 64 printable ASCII characters (A–Z, a–z, 0–9, +, /), using '=' for 4-character alignment padding. Representing 3 binary bytes as 4 ASCII bytes yields an exact 4/3 = 1.3333× size expansion before HTTP gzip or Brotli transport compression partially recovers redundancy.
What is the practical byte threshold for inlining Base64 images in CSS or HTML?
Under HTTP/2 and HTTP/3 multiplexing, separate image requests are cheap and independently cached by the browser across pages, whereas Base64 data URIs embedded inside a CSS bundle block first paint until the entire stylesheet parses and cannot be cached separately. Reserve Base64 inlining for tiny critical icons under 2–4 KB, single-file offline HTML reports, or canvas export scripts.
Do Gmail, Outlook, and Apple Mail display Base64 data:image URIs inside HTML emails?
Support across email clients is sharply fragmented: Gmail webmail and several mobile clients block data:image/* src attributes entirely and render broken image boxes, while desktop Outlook prefers MIME multipart CID (cid:) attachments or hosted HTTPS URLs. Never rely on Base64 data URIs for production marketing or transactional email templates — host images over HTTPS instead.
Can a Content Security Policy (CSP) block inlined Base64 images from rendering?
Yes. A strict Content-Security-Policy header set to img-src 'self' explicitly blocks data: URIs unless the directive includes data: (for example, img-src 'self' data: https:). If your Base64 string renders fine in a standalone test file but disappears in production, inspect your browser DevTools Console for an img-src CSP violation report.