How to use the Image to Base64 tool
- Load a pictureDrop an image into the box, click to browse, or paste a screenshot with Ctrl+V.
- Pick the outputChoose a data URI, the bare Base64 text, an HTML <img> tag, a CSS background, Markdown or JSON.
- Copy itPress “Copy” and paste directly into your code, or save it as a text file.
- Decode if requiredExpand “Decode Base64 back to an image”, paste a string, then preview or save the picture.
Encoder features
- Code snippets includedReceive the exact markup for HTML, CSS, Markdown or JSON rather than only the raw text.
- Size comparisonSee how much the encoded version grows, with a warning when a picture is too big to inline sensibly.
- Every common formatHandles PNG, JPG, WebP, GIF, SVG and ICO files.
- Both directionsTurn Base64 strings and data URIs back into a viewable, downloadable image.
- Stays on your deviceEncoding happens in your browser and pictures are never uploaded.
Base64 images in a nutshell
Base64 represents binary data, like an image file, using just 64 text-safe characters: capital and small letters, the digits 0–9, plus “+” and “/”. Encoded this way, a picture can sit right inside HTML, CSS, JSON or an email as ordinary text. Prefix it with its media type, such as data:image/png;base64,, and you have a data URI that browsers render just like a normal image address.
Good places for Base64 images
- Very small icons and logos inside CSS or HTML, saving an extra network request.
- Email templates and one-file HTML documents that can’t rely on external assets.
- APIs and JSON payloads that take images as text fields.
- Loading placeholders, like a tiny blurred preview displayed until the full picture arrives.
When to avoid it
Encoding inflates data by roughly a third (33%), because every three bytes turn into four characters. Inline pictures also can’t be cached on their own, and they bloat the HTML or CSS that has to be downloaded and parsed. A sensible rule is to inline only images under about 5–10 KB. Larger photos load faster as normal files, ideally slimmed down with our Image Compressor or converted to WebP.
The output options
- Data URI: the complete string starting with
data:image/…;base64,, usable anywhere a URL is accepted. - HTML: an image tag whose
srcattribute holds the data URI. - CSS: a
background-image: url("…")declaration ready for a stylesheet. - Markdown: the familiar
image syntax with the data URI inside.
A tip for SVG: in CSS, a URL-encoded data URI is frequently shorter than Base64, and every modern browser understands both. To encode text or other file types, use our general Base64 Encoder & Decoder.