Image to Base64
Turn an image into a Base64 data URL for HTML, CSS, Markdown or JSON, or decode Base64 back to an image.
About the Image to Base64
Turn an image into text you can paste straight into code: a data URL for an HTML <img> tag, a CSS background, Markdown or JSON, so the picture travels inside the file instead of as a separate download. SVGs can be URL-encoded instead of Base64, which is about a third smaller and still readable. It also works the other way: paste a data URL or bare Base64 text from an email, an API response or a stylesheet, and see the picture and download it as a file.
How to use it
- Choose Image → Base64 and drop an image (PNG, JPG, WebP, GIF, SVG or ICO).
- Pick what to copy: Data URL, Base64 only, HTML <img>, CSS background, Markdown or JSON string.
- For an SVG, keep URL-encoded (smaller) unless your code needs Base64.
- Click Copy, or download the text as a .txt file.
- To go back, choose Base64 → Image, paste the text and download the picture.
Tip: Inline images are worth it for small things: icons, tiny logos and placeholders under about 10 KB. A large photo as Base64 is a third bigger than the file, can't be cached on its own and delays everything after it in the page, so the tool warns you above 20 KB.
What a data URL is
A data URL puts a file's contents where a link would normally go. It starts with data:, then the file type, then the data: data:image/png;base64,iVBORw0KGgo… The Base64 part writes every 3 bytes of the file as 4 letters, digits, + or /, which is why the text is about 33% bigger than the file. Browsers read it exactly like a normal image link, in <img src>, CSS url() and anywhere else an image address is allowed.
The copy formats
- Data URL
- The full data:image/…;base64,… text. Paste it anywhere a URL to an image goes.
- Base64 only
- Just the encoded part, without data:image/png;base64, at the front. Many APIs (for example image upload and AI vision endpoints) ask for it this way, with the type in a separate field.
- HTML <img>
- A ready <img> tag with the picture's width and height, which stops the page jumping while it loads. Add a meaningful alt text.
- CSS background
- A background-image line for a stylesheet, handy for small icons and patterns.
- Markdown
- , for README files and notes. Some sites, including GitHub, don't show data URLs in Markdown, so check where you paste it.
- JSON string
- The data URL in quotes and escaped, ready to put in a JSON file or API request.
SVG: URL-encoded or Base64
SVG is already text, so it doesn't need Base64. URL-encoding only replaces the few characters that would break a URL (such as <, > and #) and changes double quotes to single quotes. The result is usually 20–35% smaller than Base64, compresses better when the page is gzipped, and you can still read and edit the SVG code inside it. The tool also removes comments and the XML declaration and collapses spaces. Choose Base64 only if a program insists on it.
Example
A 1.2 KB SVG arrow icon becomes about 1.0 KB of URL-encoded text, compared with 1.6 KB as Base64. Pasted as background-image in a stylesheet, it saves a separate request for an icon used on every page. A 2.4 MB photo, on the other hand, becomes 3.2 MB of text: the tool marks it as far too big, and a normal image file (compressed first) is the better choice.
Base64 → Image
Paste a full data URL, a CSS url("data:…") value, or bare Base64 text. The tool works out the picture type from the data itself (PNG, JPG, GIF, WebP, BMP, ICO, AVIF or SVG), so it doesn't matter if the label is missing or wrong, shows the picture and its size, and lets you download it with the right file extension. URL-safe Base64 (with - and _ instead of + and /) and missing = padding are accepted. If the text isn't a picture, or was cut off when it was copied, the tool says so.
Tips and tricks
Many email programs block data URLs in images; link to a hosted image instead.
A tiny SVG favicon as a data URL works in <link rel="icon" href="data:…"> for single-file pages.
Run a picture through the Image Compressor before encoding it; every KB saved is a third more saved as text.
A tiny, blurred 20 px version of a photo as a data URL makes a good placeholder while the full image loads.
Paste a Base64 field from a JSON response into Base64 → Image to see the picture.
Questions
Why is the Base64 bigger than my image?
Base64 uses 4 characters for every 3 bytes, so it is about 33% bigger. URL-encoded SVG avoids most of this.
Does Base64 reduce image quality?
No. It is an exact copy of the file written as text; decoding it gives back the identical file.
Is a data URL bad for SEO?
Search engines rarely index inline images and they can't be cached separately, so use normal image files for photos you want found in image search.
How do I decode Base64 to an image?
Choose Base64 → Image, paste the text and click Download image.
Can I use a data URL in an email?
Gmail and Outlook block or strip most data URL images in emails, so the picture often doesn't show. For emails, attach the image or link to a hosted copy.
Why does my decoded image not open?
The text was probably cut off when it was copied: Base64 must be complete from the first to the last character. Copy it again, including any = signs at the end.
Is there a size limit?
Images up to 25 MB. Very long results are shortened in the preview box, but Copy and Download always give the full text.
Are my pictures uploaded?
No. Everything happens in your browser, on your device. Nothing is sent to a server or stored, so private photos and unreleased designs stay private.
Related tools
Updated