Quick answer
To convert an image to Base64, drop a PNG, JPG, SVG, WebP, GIF or ICO file into the tool. It instantly shows five ready-to-use outputs: the full Data URI, Base64 only, an HTML <img> tag, a CSS background-image rule and Markdown. Click Copy next to the one you need. The conversion runs in your browser; the image is never uploaded.
- Input:
- PNG, JPG, SVG, WebP, GIF, ICO
- Outputs:
- Data URI, raw Base64, HTML, CSS, Markdown
- Size info:
- Original size vs. Base64 size
- Copy:
- One click per output
- Typical size increase:
- About 33%
- Upload needed:
- No – encoded on your device
- Speed:
- Instant
- Sign-up:
- Not required
Base64 is a way to write binary data — like the bytes of an image — using only ordinary text characters. Once an image is written as Base64, you can place it directly inside an HTML page, a CSS file, a JSON response, an email template or a Markdown document, without hosting it as a separate file. Browsers read the text and show the picture as if it had been loaded from a URL.
Our Image to Base64 converter does the encoding instantly. Drop an image in and you get five formats ready to copy: a complete data URI (for example data:image/png;base64,iVBORw0…), the raw Base64 string for APIs and databases, an HTML img tag with width and height already filled in, a CSS background-image declaration and a Markdown image.
The tool also shows the image's dimensions, its original size and the size of the Base64 text, so you can decide whether embedding is sensible. Everything happens in your browser — logos, icons and screenshots are encoded locally and never uploaded.
Need to decode text instead? Use our Base64 Encode/Decode tool for plain text and strings.
How to convert an image to Base64 – step by step
- 1 Add an imageDrop a PNG, JPG, SVG, WebP, GIF or ICO file onto the tool or click to browse.
- 2 Check the detailsThe tool shows the format, dimensions, original size and Base64 size.
- 3 Pick an outputChoose Data URI, Base64 only, HTML <img>, CSS background or Markdown.
- 4 CopyClick Copy next to the output. The code is on your clipboard.
- 5 Paste into your projectPaste it into your HTML, stylesheet, JSON, email template or document.
Why use this Image to Base64 converter?
Five ready-made formats
Data URI, raw Base64, HTML, CSS and Markdown — no manual editing.
Correct MIME type
The data URI automatically uses image/png, image/jpeg, image/svg+xml and so on.
Width and height included
The HTML tag has dimensions filled in to prevent layout shift.
Size comparison
See how much bigger the Base64 text is than the original file.
Private
Encoding happens in your browser; the image is never uploaded.
Free and instant
No limits on everyday use, no account.
What is a data URI?
A data URI is a URL that contains the file itself instead of pointing to it. It has the form data:[MIME type];base64,[data]. When the browser meets a data URI in an src attribute or a CSS url(), it decodes the Base64 and displays the image without making a network request. Data URIs work in all modern browsers, in most HTML email clients for small images and in many apps that accept image URLs.
When should you embed images as Base64?
- Small icons and logos under a few kilobytes, where saving an HTTP request matters more than the extra size.
- Single-file HTML — reports, invoices, offline pages and documentation that must work without separate image files.
- Email signatures and templates where linked images may be blocked (note that some email clients, including Gmail on the web, do not display data URIs).
- APIs and JSON that need to send an image inside a text payload.
- CSS sprites and placeholders — tiny blurred previews shown while the real image loads.
- Tests and prototypes where you do not want to set up file hosting.
When you should not use Base64
Base64 makes files about 33% larger, because every three bytes become four characters. Large photos embedded as Base64 bloat your HTML or CSS, cannot be cached separately by the browser and delay the first render of the page, since the whole document must download before anything shows. For photos and anything over roughly 10 KB, a normal image file with a URL is almost always faster. Compress large images first with the Image Compressor and serve them as files, ideally in WebP format via the Image Converter.
Base64 size compared with the original
| Original file | Base64 text (approx.) | Recommendation |
|---|---|---|
| 1 KB icon | 1.4 KB | Embedding is fine |
| 5 KB logo | 6.7 KB | Usually fine |
| 20 KB graphic | 27 KB | Consider a separate file |
| 200 KB photo | 267 KB | Use a normal image file |
Using the HTML and CSS outputs
The HTML output is a complete <img> tag with the data URI in src, an alt text based on the file name, and the image's width and height. Change the alt text to describe the image — it matters for accessibility and SEO. The CSS output is a background-image declaration you can paste into any rule; add background-size and background-repeat as needed. For SVG icons, you can often get even smaller results by minifying the SVG first and encoding it as text, but Base64 is the most compatible option.
Base64 in JSON and APIs
Many APIs, such as image recognition, OCR and AI vision services, accept images as Base64 strings in a JSON field. Use the Base64 only output — without the data:image/...;base64, prefix — unless the API documentation asks for the full data URI. Remember that JSON payloads have size limits, so resize large photos first with the Image Resizer. To check or pretty-print the JSON you send, use the JSON Formatter.
Base64 is not encryption
Base64 is an encoding, not a security measure. Anyone can decode a Base64 string back into the original image in seconds. Never use it to hide sensitive images, and do not embed private photos in public web pages thinking they are protected. For real protection of documents, use encryption such as our Protect PDF tool.
Base64 placeholders for faster-feeling pages
A popular performance trick is the "blur-up" placeholder: a tiny version of a large photo, perhaps 20 pixels wide, is embedded as Base64 directly in the HTML. It shows instantly as a soft, blurred preview while the full image downloads, so the page never looks empty and the layout does not jump. To create one, shrink the photo to about 20–40 pixels wide with the Image Resizer, save it as a low-quality JPG or WebP, convert it here and use the data URI as the CSS background of the image container, with a CSS blur filter. The placeholder usually adds less than one kilobyte per image. Frameworks such as Next.js and Gatsby generate these automatically, but for a hand-built site or a WordPress theme this manual method works perfectly.
Privacy
Because encoding uses the browser's built-in FileReader, the image is read directly from your disk into the page's memory and turned into text there. No server is involved, so you can safely encode internal logos, unreleased designs and screenshots containing personal information.
Troubleshooting
- The image does not show after pasting. Make sure you copied the full data URI including the
data:image/...;base64,prefix, and that nothing was cut off. - My editor is very slow. Very long Base64 strings can freeze some code editors. Use a smaller image.
- The image is missing in Gmail. Gmail blocks data URIs; host the image instead or attach it.
- The SVG looks wrong. Check that the SVG has width, height or a viewBox attribute.
Frequently asked questions
How do I convert an image to Base64?
Drop the image into the tool and copy the output you need — data URI, Base64, HTML, CSS or Markdown.
What image formats are supported?
PNG, JPG, SVG, WebP, GIF and ICO files.
Why is the Base64 bigger than my image?
Base64 uses four text characters for every three bytes, so it is about 33% larger.
Is my image uploaded?
No. The image is encoded in your browser and never leaves your device.
What is the difference between data URI and Base64?
The data URI includes the prefix with the MIME type, such as data:image/png;base64, followed by the Base64 data. Base64 only is just the encoded characters.
Can I use Base64 images in emails?
Many email clients support them for small images, but Gmail on the web does not. Hosted images are more reliable.
Is Base64 good for website performance?
Only for very small images. Large images should be served as normal files so they can be cached.
How do I convert Base64 back to an image?
Paste the data URI into your browser's address bar to view it, or decode it with a Base64 decoder.
Is Base64 secure?
No. It is an encoding anyone can reverse, not encryption.
Does it work on mobile?
Yes. Choose an image from your phone and copy the code.
Last updated November 21, 2026 · Written and tested by the SmallEasyTools team.