Image to Base64
Image to Base64 turns a PNG, JPG, GIF, WebP, SVG or icon file into Base64 text you can paste into HTML, CSS, JSON or an email template, and turns Base64 or a data URI back into an image you can see and download. Your image stays on your device.
Choose an image to see its Base64 text.
Your image never leaves this device. The conversion runs in your browser.
What is the Image to Base64?
Image to Base64 converts picture files into text and back. Base64 writes any file using 64 safe characters, so an image can live inside an HTML page, a CSS file, a JSON API request or a config file instead of as a separate file. Choose an image and you get a ready data URI, the plain Base64, a CSS background-image line, an HTML img tag or a Markdown image, with the size shown so you can judge whether embedding makes sense. You can shrink a large picture to icon size first. Switch to Base64 to image to paste a data URI or raw Base64 from code or an API and see the picture, its real type and its size, then download it. Front-end developers, email builders, API testers and students use it.
Who it is for: Front-end developers, HTML email builders, people testing APIs that send images as Base64, students learning web development, and anyone who finds a long data:image string and wants to see the picture.
How to use the Image to Base64
- Choose Image to Base64, then pick or drop an image.
- Choose the output: data URI, Base64 only, CSS, HTML or Markdown.
- For icons, pick a smaller size to keep the text short.
- Copy the result. To go back, choose Base64 to image and paste the text.
Why use it
- Five ready formatsGet a data URI, plain Base64, a CSS line, an HTML img tag or a Markdown image without editing anything by hand.
- Decodes tooPaste Base64 or a whole data URI, even with line breaks or URL-safe characters, and see the image and its real type.
- Honest about sizeIt shows how many characters you get and warns when an image is too big to embed sensibly.
- PrivateLogos, screenshots and ID images are never uploaded. Everything runs in your browser.
At a glance
- What you put in
- One image (PNG, JPG, GIF, WebP, SVG, AVIF, BMP or ICO) up to 10 MB, or pasted Base64 or a data URI
- What you get
- Data URI, plain Base64, CSS background-image, HTML img tag or Markdown image; or a decoded image to preview and download
- Limits
- One image at a time, up to 10 MB; shrinking keeps PNG, JPG and WebP types (GIF and SVG are kept as they are); Base64 is about 33% larger than the file
- Privacy
- Runs in your browser. Nothing you enter is uploaded or stored.
- Price
- Free for everyone. No subscriptions, no payments, no watermark.
- Works offline
- Yes, once the page has loaded
- Last checked
- by AK Shine
Worked example
The 1200 × 800 px sample PNG (936 KB), Keep the original file, output as Data URI
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAABLAAAAMg... with 1,278,508 Base64 characters, 1,278,530 characters in all
Base64 writes every 3 bytes as 4 characters, so 958,880 bytes become 4 × 319,627 = 1,278,508 characters, 33% more than the file. The tool warns that this is too big to embed. Shrunk to 128 × 85 px, the same picture came to 19,636 characters in Chrome; the exact number depends on the PNG encoder in your browser.
When to use something else
- Embed only small images, such as icons and logos under a few KB. A large Base64 image cannot be cached on its own, makes your HTML or CSS slower to load and is about a third bigger than the file. For photos, upload the file and link to it.
- Gmail and several other email apps do not show data URI images in emails. For email, attach the image with a Content-ID or host it and use a normal link.
Questions people ask
What is a data URI?
It is a way to put a whole file inside a link. It starts with data:, then the file type such as image/png, then ;base64, and then the Base64 text. Browsers show it like a normal image address as the src of an img tag or inside CSS url().
Why is the Base64 bigger than my image?
Base64 uses 4 text characters for every 3 bytes, so the text is about 33% larger than the file, plus 22 or so characters for the data:image/png;base64, start. Gzip on a web server wins back only part of that.
When should I embed an image as Base64?
For tiny images used on one page, such as a small icon, a loading spinner or a logo in a single HTML file that must work offline. For anything larger, a separate file is faster because the browser can cache it and load it in parallel.
How do I convert Base64 back to an image?
Choose Base64 to image and paste the text. You can paste raw Base64, a full data URI, or even a whole HTML img tag or CSS line. The tool finds the Base64, shows the picture, and lets you download it with the right file extension.
Why does my Base64 not show an image?
It may be cut off when it was copied, it may not be an image at all, or it may be a format your browser cannot show. The tool tells you which: a length that is impossible, characters that are not Base64, or data that is not a known image type.
Should I use Base64 for SVG files?
It works, but SVG is already text. In CSS, a URL-encoded SVG data URI is usually smaller than a Base64 one. For an SVG used in HTML, pasting the <svg> code directly is often the simplest choice.
Is Image to Base64 free and private?
Yes. It is free with no subscriptions, and your images are read only by your own browser. Nothing is uploaded, so you can use it for private screenshots and documents.