Image to Base64
Encode an image as Base64, CSS or an HTML tag.
- 1Upload
- 2Settings
- 3Download
How to use Image to Base64
About Image to Base64
Base64 turns binary data, such as an image, into plain text made of letters, digits, +, / and =. That text can be pasted into HTML, CSS, JSON or an email template, which is handy when you cannot or do not want to host a separate image file.
A data: URI wraps the encoded image so a browser can display it directly, for example data:image/png;base64,iVBORw0KGgo…. This works well for tiny icons and small placeholders. Base64 makes data about one third larger, and the browser cannot cache an inline image separately, so it is a poor choice for large photos.
How it works: the tool reads your image file and encodes its bytes as a Base64 text string, optionally as a ready-to-use data URI. You can paste that string straight into HTML, CSS, JSON or an email template so the picture travels inside the text rather than as a separate file.
Step by step: 1) add the image; 2) copy the Base64 or data URI output; 3) paste it where you need it, for example in an img src attribute or CSS url(). Test it in your page to make sure it displays.
Realistic limits: Base64 makes data about one third larger than the binary file, and inline images cannot be cached separately by the browser. It suits small icons and logos, not large photos. A big image yields a very long string that can be awkward in editors and may exceed size limits in some systems. Encoding happens locally.
Typical uses: embedding a small logo in an HTML email, avoiding an extra network request for a tiny icon, or putting an image in a JSON payload for an API test.
Using the output: in HTML, a data URI goes into the src attribute of an img tag; in CSS it goes inside url(). In JSON, store only the Base64 portion if the receiving system expects raw data, or the full data URI if it expects that. Check which one your API documentation asks for, since adding or omitting the prefix is the most common cause of broken images.
Good practice: keep inline images tiny, since they are downloaded with the page every time and make source code hard to read. For anything over a few kilobytes, a normal image file is usually better because browsers can cache it. SVG icons are often better written directly as markup than as Base64.
Tips for better results
- Keep inline images under a few kilobytes; use normal image files for anything larger.
- Compress or resize the image first to keep the text short.
- SVG icons are often better embedded as plain text than Base64.
- To turn encoded text back into a picture, use Base64 to image.
- Compress or resize first so the string stays short.
- Keep inline images under a few kilobytes where possible.
- Base64 is encoding, not encryption; it hides nothing.