Image to Base64 Converter – File to Data URI
Images in, data URIs out — paste-ready.
At a glance
- Input:
- JPG · PNG · SVG · WebP · GIF · AVIF
- Output:
- Base64 string, data URI, <img> tag or CSS rule
- Processing:
- Runs locally in your browser
- Privacy:
- Nothing you type is sent to a server
Last updated: 2026-11-11
Common use cases
- Inlining a small logo into an HTML email where external images are blocked
- Embedding an icon in a stylesheet as a CSS background-image without another HTTP request
- Pasting a thumbnail into a single-file HTML demo or a code snippet
- Turning a Base64 string from an API response back into a downloadable image
About this tool
Drop an image and get everything you can paste: the raw Base64 string, the full data URI, a ready <img> tag, and a CSS background-image rule — with a live preview and the byte size before and after, so the +33% cost of Base64 is never a surprise. Up to 20 files at once, JPG, PNG, SVG, WebP, GIF and AVIF, all converted locally in your browser. The reverse mode turns a pasted data URI or Base64 string back into a downloadable image.
How to use it
- Drop one or up to 20 images — JPG, PNG, SVG, WebP, GIF or AVIF, 10 MB each.
- Pick a file to see its preview and its sizes: original bytes, Base64 characters, and the full data URI.
- Switch between the four output tabs — Raw Base64, Data URI, <img> tag, CSS — and copy the one you need.
- To go the other way, switch to Base64 → Image mode, paste a data URI or raw Base64, and download the image.
Worked examples
Input: 100 KB photo (102,400 bytes) · PNG
Output: 136,536 Base64 characters — about 133 KB of text, +33.3% — data URI 136,558 characters
Verified against the real module: base64Length(102400) = 136,536; the 22-character data:image/png;base64, prefix makes the full data URI 136,558 characters.
Input: 1 KB icon (1,024 bytes) · PNG
Output: 1,368 Base64 characters (+33.6%) — 1,390 characters as a data URI
Verified: ceil(1024/3)×4 = 1,368; +22 for the data:image/png;base64, prefix = 1,390.
Input: Built-in sample SVG star (229 bytes)
Output: 308 Base64 characters (+34.5%) — 334-character data URI, ready to paste as an <img> tag
Verified: the sample is 229 bytes; utf8ToBase64 gives 308 characters and the 26-character data:image/svg+xml;base64, prefix makes 334.
Practical tips
- Use data URIs for assets under a few KB — a 1 KB icon costs 1,368 characters; a 100 KB photo costs 136,536.
- Copy the <img> tab when you paste into HTML and the CSS tab when you paste into a stylesheet — the quoting is already done.
- Convert a batch of icons at once (up to 20 files) and copy each output from the file list.
- For a single-file HTML demo, the data URI keeps everything in one file — but remember it cannot be cached separately.
Common mistakes
- Inlining a photo as a data URI — a 100 KB photo becomes 133 KB of text that the browser re-parses on every load.
- Pasting the raw Base64 into an <img> src without the data: prefix — the browser needs the prefix to know it is an image.
- Forgetting the image type in reverse mode — raw Base64 has no format information, so pick PNG, JPG, SVG, WebP, GIF or AVIF.
- Uploading a 50 MB photo and wondering why the tab froze — the 10 MB cap exists because the Base64 string would be ~67 MB.
How this compares
Most image-to-Base64 tools in the field show one output — the raw string — and hide the size cost. This one shows all four paste-ready outputs (raw Base64, data URI, <img> tag, CSS), the exact before/after sizes for every file, a batch of up to 20 files, and a reverse mode that turns Base64 back into a downloadable image. The tradeoff: it converts files, not text — for Base64 text, use the Base64 encoder/decoder, which is the text sibling of this tool.
Good to know
- Base64 adds about a third: a 100 KB file becomes ~133 KB of text, and the browser re-parses it on every page load.
- Data URIs cannot be cached separately from the page — they are wrong for photos and large images.
- 10 MB per file, 20 files at once — larger files are refused with a named error instead of freezing the tab.
- The reverse mode needs a valid image data URI or valid Base64; a truncated paste is rejected, not guessed at.
Frequently asked questions
Are my images uploaded anywhere?
No. The conversion runs entirely in your browser with FileReader — the file is read, encoded, and shown in this tab, and never sent to a server. That is the whole point of this tool over a server converter.
Why is the Base64 text bigger than my image?
Base64 encodes every 3 bytes as 4 characters, so the text is always about a third larger. A 100 KB photo (102,400 bytes) becomes 136,536 characters — about 133 KB of text, +33.3% — before the data: prefix is added. The page shows the exact before/after sizes for every file.
When should I use a data URI instead of a normal image file?
For small assets only — icons, logos, thumbnails. A data URI cannot be cached separately from the page, and the browser must parse the whole string on every page load. A photo belongs as a normal file; a 2 KB logo is a good data URI.
What is the difference between the raw Base64 and the data URI?
The data URI is the raw Base64 with a prefix that tells the browser what it is — data:image/png;base64, for a PNG, 22 characters. Browsers need the prefix to display it; APIs and databases usually want the raw string without it. This tool gives you both, plus the <img> tag and the CSS rule.
Can I convert a Base64 string back into an image?
Yes — switch to the Base64 → Image mode, paste a full data URI or just the Base64 characters, and download the image. A raw Base64 paste needs you to pick the image type (PNG, JPG, SVG, WebP, GIF or AVIF) so the download gets the right format.
Why is there a 10 MB limit per file?
A 50 MB photo would become a roughly 67 MB string, and building a string that large freezes the tab. The 10 MB cap keeps the conversion instant, and the tool refuses oversized files with a named error instead of hanging.
Which image formats can I convert?
JPG, PNG, SVG, WebP, GIF and AVIF — up to 20 files at once. SVG is text, so it converts exactly; AVIF and WebP convert byte-for-byte like the rest. For text (not files), use the Base64 encoder/decoder instead.

