Image to Base64 Converter
Drop in a PNG, JPG, SVG, WebP or GIF and instantly copy its Base64 string and data URI — ready to paste into your HTML, CSS or JavaScript. One click to copy.
100% client-side. Your image never leaves your device.
Want the reverse? Decode a string back with the Base64 to Image tool.
Drop an image to convert it to Base64
or paste from clipboard · max recommended ~5 MB
How to convert an image to Base64
An image file is binary data. Base64 rewrites those bytes as text using 64 safe characters
(A–Z, a–z, 0–9, + and /). Add a small header like data:image/png;base64,
and you get a data URI — a self-contained string the browser treats exactly like a normal image
URL, except the picture is baked into the text. People search for this the same operation under several names:
image to Base64, base64 encode image, image base64, encode image to Base64,
and convert image to Base64 online all mean the same forward step — a file goes in, a string comes out.
- Add your image. Drag a file onto the converter, click Choose image, or paste it from your clipboard.
- Copy the result. The page instantly shows the full data URI plus ready-made HTML and CSS snippets. Hit Copy on whichever one you need.
- Paste it into your code. Drop the data URI into an
<img>tag, a CSSbackground, a JSON payload, or anywhere a string belongs.
Image to Base64 vs Base64 to image
These are opposite directions and are easy to mix up. Image to Base64 (this page) encodes a file into text so you can embed it. Base64 to image decodes a string back into a downloadable file. If you have a string and need a file, open the Base64 to Image decoder; if you have a file and need a string, stay here.
What the image Base64 output looks like
A raw Base64 string contains only encoded image data — for a PNG it commonly begins with
iVBORw0KGgo, the Base64 signature of the PNG header. A data URI adds the MIME-type
prefix data:image/png;base64, before that string. Browsers need the prefix when the result is placed
directly in an image source or CSS rule; APIs and databases sometimes want only the raw body. Use the format the
destination requires rather than stripping the prefix by guesswork.
<!-- HTML -->
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUg..." alt="logo" width="32" height="32" />
/* CSS */
.logo { background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUg...); }
When to inline an image as Base64
- Small interface assets: an icon, badge, spinner or logo where removing an extra request helps.
- Single-file deliverables: an email template, self-contained HTML report, or a CMS field that rejects file uploads.
- Prototypes and test fixtures: a CodePen, JSON mock, or demo that needs an image without hosting it.
- Text-only storage: a system that accepts strings but cannot receive a separate binary upload.
Inline only when portability or fewer requests is worth the extra bytes. For a normal production site, an optimized image file is usually easier to cache, replace and deliver through a CDN.
When a normal image file is better
Keep large screenshots, photos and hero graphics as regular files. Base64 adds roughly one third to the binary size, and an inline image cannot be cached independently from the HTML or CSS that contains it. Reusing the same long data URI across several pages repeats bytes that a separately hosted image could download once. Normal files are usually better for responsive images, lazy loading, CDN resizing and content that changes often.
Why Base64 output is larger
Base64 represents every three input bytes with four text characters, so the encoded body is about 33% larger than the original image. HTTP compression may shrink the transfer difference when the string is embedded in a compressed HTML or CSS file, but it does not remove the browser's decode work or restore independent caching. Compare the final compressed page size rather than assuming every inline image improves performance.
Private, browser-only conversion
The converter uses the browser's FileReader API. Your image is read on the current device and the result
is written into the output fields; the file is not uploaded to this site. That makes the tool suitable for internal
screenshots and design assets, although you should still avoid pasting a sensitive result into third-party forms,
public issue trackers or source code that will be published.
Security note for Base64 images
Base64 is an encoding, not encryption. Anyone who receives the string can decode the original image. Treat the output with the same care as the source file, and do not use encoding as a way to hide confidential content. If you accept Base64 from other users in an application, validate the declared MIME type, decoded size and file signature before storing or displaying it.
More Base64 converters
One focused tool per format. All free, all client-side.
Frequently asked questions
What does image to Base64 mean?
Image to Base64 rewrites an image file's binary bytes as plain text using the Base64 encoding, producing a string — or a data URI — that can be embedded directly in HTML, CSS, JSON or JavaScript instead of referencing a separate file.
Is the image to Base64 conversion private?
Yes. Conversion runs entirely in your browser via the FileReader API. Your image is never uploaded — there is no network request, so even private or sensitive images stay on your device.
How do I use an image Base64 data URI in HTML and CSS?
Use the full data URI. In HTML: <img src="data:image/png;base64,iVBORw0K...">. In CSS: background-image: url(data:image/png;base64,iVBORw0K...). This page gives you ready-to-paste snippets.
What image formats can I convert to Base64?
Any image your browser can read: PNG, JPG/JPEG, GIF, WebP, SVG, BMP and ICO. The data URI automatically carries the correct MIME type for the file you choose.
Is "base64 encode image" the same as "image to Base64"?
Yes. "Image to Base64", "base64 encode image", "image base64" and "encode image to Base64" all describe the same forward operation: an image file goes in, a Base64 string comes out.
What is the difference between image to Base64 and Base64 to image?
They are opposite directions. Image to Base64 encodes a file into text (to embed it); Base64 to image decodes a string back into a file. If you have a string and need a file, use the Base64 to Image decoder.
Does Base64 make my image larger?
Slightly — about 33% larger than the raw file, since it uses 4 text characters per 3 bytes. Fine for small icons and logos; for large photos, keep them as normal image files.
When should I use image to Base64 instead of a normal image file?
Use it for small, frequently-used assets (icons, logos), single-file deliverables (email templates, self-contained reports), and quick prototypes. Keep large photos and hero images as normal files so they can be cached and delivered efficiently.