Image to Base64
Convert a JPG, PNG, GIF, SVG or WebP image into a Base64 string or data URI for HTML, CSS, JSON and email templates. Free image to Base64 converter.
Turn an image into text you can embed
Converting an image to Base64 turns the file into a long string of text. You can then embed it directly in a web page or stylesheet as a data URI, for example <img src="data:image/png;base64,iVBOR...">, put it in a JSON payload, or store it in a text field, with no separate image file needed.
Upload an image and copy the encoded result. The tool gives you the raw Base64 only, so add the data:image/png;base64, prefix (with the right image type) yourself when you build a data URI. It's a common trick for small icons, logos in HTML email signatures, placeholder images and assets in single-file demos.
There's a trade-off: Base64 makes the data about a third larger than the original file, and embedded images can't be cached separately by the browser. Use it for small images and keep large photos as normal files.
How to use the image to base64
- Choose the image file from your device.
- Let the tool encode it.
- Copy the Base64 output.
- Paste it into your HTML
src, CSSurl(), JSON or code.
Examples
A tiny PNG
Input: A 69-byte, 1×1 pixel PNG
Output:
iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR42mPonL4bAAOIAdw0rRDJAAAAAElFTkSuQmCC
92 characters of Base64, about a third more than the 69-byte file.
Using the result in HTML
Output: <img src="data:image/png;base64,iVBORw0KGgo..." alt="">
Add the prefix that matches the file type: image/png, image/jpeg, image/gif, image/webp or image/svg+xml.
Common uses
- Embedding small icons and logos directly in HTML or CSS.
- Including images in single-file HTML demos and prototypes.
- Sending images inside JSON to an API that expects Base64.
- Building email templates (note that some email apps block data-URI images).
- Storing small images in databases or config files.
Tips and things to know
- Optimize the image first with the image optimizer; a smaller file means a much shorter string.
- Base64 is best for images under a few kilobytes. Larger images load faster as normal cached files.
- Gmail and some other clients don't display data-URI images in emails. Host important email images instead.
- Check the result by pasting it into Base64 to image.
Edge cases and limitations
- Uploads are limited by the site's maximum file size; the tool shows an error above it.
- The output is one long line with no breaks, which is what data URIs need.
- SVG files are text already. For SVG you can often skip Base64 and embed the URL-encoded SVG directly, which is shorter.
Frequently asked questions
What is a data URI?
It's a URL that contains the file's data itself, like data:image/png;base64,... Browsers display it just like a linked image.
Does Base64 make images bigger?
Yes, by about 33%, because every 3 bytes become 4 characters.
Is Base64 good for website performance?
For tiny images it can save an HTTP request. For larger images it usually hurts, because the page HTML or CSS gets heavier and can't be cached separately.
Which image formats are supported?
Common web formats such as JPG, PNG, GIF, WebP and SVG.
Related tools
- Base64 to Image: Decode Base64 input to an image.
- Image optimizer: Compress and optimize images for a smaller image size but still high quality.
- Base64 encoder: Encode any string input to Base64.
- Color picker: The easiest way to select a color from the color wheel and get the results in any format.
- Exif reader: Upload a image and extract the data out of it.
Similar tools
Paste a Base64 string or data URI and see it as an image you can view and save. Debug embedded images in HTML, CSS, JSON and emails. Free decoder.
Popular free tools
Convert text to UPPERCASE, lowercase, Sentence case, Capital Case, camelCase, PascalCase, snake_case, CONSTANT_CASE, dot.case or param-case. Free.
Look up the DNS records of any domain: A, AAAA, CNAME, MX, NS, TXT and SOA. Check email, SPF, verification and nameserver settings for free.
Create strong, random passwords in one click. Pick the length and include uppercase, lowercase, numbers and symbols. Free, no signup.
Encode any text or string to Base64 instantly. Useful for data URIs, HTTP Basic auth headers, email and APIs. Free online Base64 encoder.
Convert numbers into words, such as 1,250 to “one thousand two hundred fifty”. Write checks, invoices, legal documents and lessons correctly. Free.
Turn normal text into elegant 𝓬𝓾𝓻𝓼𝓲𝓿𝓮 letters you can copy and paste into Instagram, TikTok, X and Discord bios, captions and names. Free.