Drop, paste or choose an image to get its Base64 code instantly: a ready-to-use data URI, raw Base64, a CSS background rule or an HTML img tag. Your images never leave your device.
Drop images here or choose files
PNG, JPG, WebP, GIF, SVG, AVIF, ICO, BMP · or paste with Ctrl+V
Sample image
Type
-
Dimensions
-
File size
-
Base64 size
-
0 charactersLong output: the box shows the first 200,000 characters. Copy and Download use the full string.
Advertisement
Advertisement
How to use the Image to Base64
Add an image: drag it onto the drop area, click to choose a file, or paste a screenshot with Ctrl+V. You can add several at once.
Pick a format from the tabs: Data URI, Base64 only, CSS, HTML <img>, Markdown or JSON.
Optionally shrink it: choose Re-encode as WebP or JPEG and set a max width to get a much shorter string.
Copy or download the code and paste it into your HTML, CSS, JSON or email template.
Switch images with the thumbnails if you added more than one.
How Base64 image encoding works
Base64 reads the file 3 bytes (24 bits) at a time and splits them into four 6-bit groups. Each group is a number from 0 to 63 that maps to one character of the alphabet A–Z a–z 0–9 + /. If the file length is not a multiple of 3, the last group is padded with one or two = signs. That is why the encoded size is always 4 × ⌈bytes ÷ 3⌉ characters, about 33% more than the original file.
A data URI wraps that text with the file type so browsers know how to decode it: data:[MIME type];base64,[data]. For example a PNG starts with data:image/png;base64,iVBORw0KGgo, because every PNG file begins with the same 8 signature bytes.
Where to use each output
Output
Use it for
Example
Data URI
Any place that accepts a URL: img src, CSS url(), JavaScript, canvas
data:image/png;base64,iVBOR…
Base64
APIs and JSON fields that expect only the encoded bytes, email MIME parts
iVBORw0KGgoAAAANSUhEUg…
CSS
Small icons and background patterns inside a stylesheet
background-image: url("data:…")
HTML <img>
Single-file HTML pages, email templates, offline docs
<img src="data:…" alt="logo">
Markdown
README files and notes that must embed the picture

JSON
Sending an image with its name, type and size to an API
{"mime": "image/png", "base64": "…"}
Tips for shorter Base64 strings
Inline only small files. Icons under about 5 to 10 KB are good candidates. Larger images are better served as normal files that the browser can cache.
Re-encode photos as WebP or JPEG and set a max width close to the size you actually display. A 4000 px phone photo shown at 400 px can shrink by more than 95%.
Keep PNG for flat graphics with sharp edges or transparency. JPEG has no transparency, so transparent areas are filled with white.
SVG icons are often smallest as SVG. Minify the SVG first, then encode it.
Email: many email clients, including Gmail, block data URI images. For email, attach the image or host it instead.
Frequently asked questions
What is a Base64 image?
It is the image file's bytes written as text using 64 safe characters (A-Z, a-z, 0-9, + and /). Put inside a data URI such as data:image/png;base64,..., it can be used directly in an img src, a CSS url() or JSON without a separate file.
Why is the Base64 string bigger than the image?
Base64 turns every 3 bytes into 4 characters, so the text is about 33% larger than the original file (plus a few characters of padding and the data URI prefix). Gzip or Brotli compression on your server wins some of that back.
When should I inline images as Base64?
It is useful for small icons, logos and placeholders (a few KB), for single-file HTML pages, email templates and JSON APIs. For large photos a normal image file is better because it can be cached separately and does not bloat your HTML or CSS.
Are my images uploaded to a server?
No. The file is read with the browser's FileReader API and encoded on your device. Nothing is sent anywhere, so it is safe for private screenshots and unreleased designs.
Can I convert SVG to Base64?
Yes. SVG files are encoded exactly like other images and get the image/svg+xml MIME type. For SVG you can also use a URL-encoded data URI, but Base64 works everywhere and avoids escaping problems.
How do I turn Base64 back into an image?
Use the Base64 to Image tool: paste the data URI or raw Base64 and it shows a preview, detects the file type and lets you download the image.
Is there a size limit?
There is no fixed limit, but very large strings (tens of MB) can make the page slow. For big photos, use the re-encode option to resize and compress first.