Image to Base64 Encoder
A fast online image to Base64 encoder. Convert an image to a Base64 string or data URI — paste it into HTML, CSS, JSON, or an API payload in seconds.
Use this image to Base64 encoder to convert PNG, JPG, WebP, GIF, or SVG into a Base64 string. Pick raw output, a full data URI, a CSS url() wrapper, or a complete <img> tag — whichever you need.
Ideal for embedding small icons in a stylesheet, inlining avatars in email templates, or posting images in a JSON API call. Everything runs in your browser — files never leave your device.

How to encode an image to Base64
Three steps from file to ready-to-paste string.
1. Upload
Drop an image — PNG, JPG, WebP, GIF, or SVG.
2. Pick format
Raw Base64, data URI, CSS url(), or full <img> tag.
3. Copy
One-click copy. Paste wherever you need it.
Output formats
Pick the shape that matches where the string will live.
Raw Base64
iVBORw0KGgoAAAANSUhEUgAAAAUA...
Just the encoded characters. Pass to any Base64 parser.
Data URI
data:image/png;base64,iVBORw0KGgo...
Includes the MIME prefix — drop directly into <img src>, CSS url(), or JSON.
CSS url()
url('data:image/png;base64,iVBORw0KGgo...')Ready to paste into background-image or content in a stylesheet.
HTML <img>
<img src="data:image/png;base64,..." alt="" />
Full markup ready for a page or email body.
Typical reasons to encode images as Base64
Embed an image in CSS
Turn a small icon into a data URI so you don’t need an extra HTTP request.
Inline in HTML / JSX
Paste an <img src="data:..." /> string directly into a component or email template.
Send in an API payload
Post an image inside JSON (e.g. to a webhook or LLM endpoint) without multipart uploads.
Bundle into a single file
For scripts and offline demos, Base64 images remove the need for separate asset files.
Common pitfalls
Encoding very large images
Base64 makes the string ~33% bigger than the source file. For anything bigger than a small icon, serving the image from a URL is still better.
Using data URIs for above-the-fold photos
Browsers can’t cache inline Base64. Real URLs win for images that repeat across pages.
Mixing MIME types
Don’t claim image/png in the data URI if the source is JPG. The browser might decode, but some tools will fail.
Pasting giant strings into tooling
IDEs and linters choke on multi-megabyte Base64 strings. Keep Base64 images small and reference larger assets by URL.
What this tool supports
| Feature | Supported | Notes |
|---|---|---|
| Encode image to Base64 | Yes | PNG, JPG, WebP, GIF, SVG, BMP, and more. |
| Output as data URI | Yes | Includes MIME type, ready for HTML / CSS / JSON. |
| Copy to clipboard | Yes | One click to copy the encoded string. |
| Batch encode | Yes | Upload multiple images; get a list of strings or a .txt. |
| Size preview | Yes | See how much the Base64 string is after encoding. |
| URL-safe output (optional) | Yes | Swap + / for - _ when needed by your system. |
| Account required | No | No signup, no install. |
Frequently Asked Questions
User reviews
No reviews yet. If you used the tool, you can share feedback on our feedback page.
Ready to encode your image?
Drop a file, pick a format, and copy the Base64 string or data URI in seconds.

