Image to Base64
Turn a picture into a data URI, an img tag or a CSS background rule — encoded in this tab and handed back as a file to open.
What this tool does
Image to Base64 reads the bytes of your picture, re-expresses them in the 64 printable characters Base64 allows, and puts the correct MIME type in front of the result. That type comes from what the browser reports about the file; when the browser says nothing, the signature in the first few bytes decides between JPEG, PNG, WebP, GIF, AVIF and BMP, then the extension is consulted, and .svg is trusted last of all, because SVG is text and carries no signature to read. Those six plus SVG are the whole fallback list, so a HEIC or TIFF the browser declines to type is refused rather than guessed at.
The same encoded string is offered in five shapes, because where it is going decides the wrapper it needs. A data: URL is the plain value; Base64 on its own drops the prefix, with optional wrapping at 76 characters; and the img tag, the CSS background rule and the Markdown syntax each paste straight into that kind of document. The CSS rule takes its class name from the source file, with punctuation folded to hyphens, and sets background-size to cover.
Base64 costs about a third more than the original — four characters for every three bytes — so a 30 KB icon arrives as roughly 40 KB of text. Read the percentage in the summary carefully: it weighs the encoded characters against the original bytes and stops there, so the data: prefix, the img tag or the CSS rule around them is counted in the byte figures beside it but not in the percentage itself. Past 20 KB the summary adds a warning, because bytes carried inside a document cannot be cached on their own and are re-sent with every copy of the HTML or CSS holding them.
The work happens in this browser tab, so the image is not uploaded and nothing about it is stored. Three ceilings shape what comes out. The text is never printed on screen: the result panel gives a summary, a few figures and a download, so the data: URL is read by opening the saved file rather than copied from a box. Nothing is resized or recompressed, so a 2 MB photograph becomes about 2.7 MB of text. And when several images go in together, each becomes its own download, with a ZIP of the set, while the single summary line above them describes the last file only.
How to use it
- Choose an image. Anything the browser types as an image is taken; PNG, JPG, WebP, GIF, AVIF, BMP and SVG are also recognised on their own. A file that is not an image is refused rather than encoded blindly.
- Pick what you want back. A data: URL, Base64 with no prefix, an img tag, a CSS background rule or Markdown image syntax. The remaining settings change to match that choice.
- Set the details that apply. Alt text for the img tag, which is HTML-escaped so quotes and angle brackets in your description cannot break the markup — or wrapping at 76 characters for raw Base64.
- Save the file, then open it. The encoded text does not appear on the page. It arrives as a download named after the source image, with a .txt, .html, .css or .md extension to match the output you picked.
Processing & privacy
Runs on your device. Your file is processed directly in this browser.
Common use cases
Inlining a small icon in CSS
A 2 KB logo carried inside a background-image rule is one request fewer on first paint. The CSS output writes the whole rule, class name included.
Putting an inline image in an HTML email
Base64 wrapped at 76 characters is the line length MIME bodies expect, which keeps the value intact where one very long line would be mangled.
Making a page that carries its own pictures
A bug report or a single-file demo that embeds its screenshots survives being emailed, copied or opened from disk with no assets folder beside it.
Dropping a fixture into a test
A data URI drops into a unit test, a component story or a JSON payload, where a file path would need a server or a build step behind it.
Questions
Is my image uploaded anywhere?
Where does the encoded text appear?
How much bigger is the encoded version?
When should I not inline an image?
Does it compress or resize the picture first?
Why does my Markdown carry the file name as its alt text?
Can I encode a PDF or a font this way?
What happens if I select several images at once?
Related tools
- Image Compressor — Shrink JPG, PNG and WebP files with a quality you control.
- Resize Image — Change pixel dimensions with aspect-ratio locking.
- Convert Image — Convert between JPG, PNG, WebP, AVIF and GIF.
- PNG to JPG — Convert PNG files to smaller JPG images.
- HEIC Converter — Convert iPhone HEIC photos to JPG or PNG.
- Compress to Target Size — Compress an image until it fits an exact size budget.