Image to Base64 Converter
Convert any JPG, PNG, WebP, GIF or SVG into a Base64 data URI, and decode a Base64 string back into a downloadable image in the same tab. The MIME type is detected for you, the preview confirms what you are about to copy, and the size readout tells you whether inlining is really worth it.
Base64 turns binary bytes into plain ASCII, which survives copy-paste, JSON payloads, CSS rules and email threads that would otherwise mangle an attachment. The trade-off is size: the encoded text is roughly 33% longer than the original file. All processing runs locally in your browser. Your data is not uploaded to any server. 100% Local
How to Use Image to Base64
- Choose a direction โ pick Image โ Base64 to encode a file, or Base64 โ Image to turn a pasted string back into a picture.
- Load the source โ click the drop box, drag a file onto it, or copy an image and press
Ctrl/โ+V. - Check the detected MIME type โ the data URI prefix (
image/png,image/jpeg,image/webp) comes from the file content, not the file name. - Pick the output shape โ keep Full data URI for HTML and CSS, or switch to Raw Base64 for JSON fields and API bodies.
- Read the size line โ it shows pixel dimensions, the original byte size and the expanded Base64 length before you paste anything.
- Copy or download โ use the plain copy button, the ready-made
<img>tag, the CSSurl()wrapper, or save the string as a .txt file. - Decode in reverse โ paste a full data URI or a bare Base64 body; the decoder recognises the prefix or sniffs the first bytes for a PNG, JPEG, GIF, WebP or BMP signature.
- Preview and save โ confirm the decoded image, then download it with the extension that matches the detected format.
Choosing between a data URI and raw Base64
A data URI carries the data:image/png;base64, header, so it can be dropped straight into an src attribute, a CSS url() or a Markdown image tag without further work. Raw Base64 is only the character payload โ the right choice when a JSON API expects a string field, when you are storing the value in a database column, or when the consumer already knows the format. If you are unsure, take the full data URI: it is self-describing.
Keeping the payload small
Base64 is not compression. A 200 KB photo becomes roughly 270 KB of text, and HTML attribute quoting plus UTF-8 encoding can push the effective transfer size higher again. For icons, logos, spacers and one-pixel placeholders under about 10 KB this is irrelevant; for anything larger, shrink the image first with an image compressor, then encode the smaller result.
Features
- Two directions in one page: encode an image to Base64 and decode Base64 back to an image.
- Automatic MIME detection from the data URI header, plus byte-signature sniffing for bare Base64.
- Copy as raw text, a ready-to-paste
<img>tag, or a CSSurl()declaration. - Download the encoded string as a .txt file, or the decoded result as PNG, JPG, WebP, GIF or BMP.
- Original byte size and encoded length shown side by side so you can judge payload growth.
- Toggle between full data URI and raw Base64 output without reloading the file.
- Drag-and-drop, click-to-browse and clipboard paste all work for the encode side.
- Decoded preview reports pixel dimensions, detected format and file size.
- Accepts JPG, PNG, WebP, GIF, BMP, SVG and anything else the browser can decode.
- No upload, no queue, no account and no daily conversion limit.
- All processing runs locally in your browser. Your data is not uploaded to any server.
- Limit: encoded text is about 33% larger than the binary file, so large photos gain nothing from inlining.
When to Use Image to Base64
Inlining small assets in HTML and CSS
Icons, bullet diamonds, loading spinners and one-pixel spacers can travel inside the stylesheet or the markup as data URIs. That removes a request round-trip on a cold load and guarantees the asset renders even when the network stalls. Keep each embedded file under roughly 10 KB, prefer SVG or PNG for crisp edges, and remember that the same string is re-downloaded with every page that references it.
Embedding images in JSON, YAML and email
Configuration files, test fixtures, fixtures in a codebase and transactional email templates cannot reference a local path. A raw Base64 field keeps the payload self-contained: one JSON object or YAML block carries both the metadata and the picture. This is common for sample data in automated tests, for storing tiny thumbnails in a database, and for HTML emails where external images are often blocked by default.
Recovering an image you were sent as text
Developers often receive a Base64 dump in a chat message, a log file or a bug report with no file attached. Paste it into the decode tab and you get a real preview plus a correctly named download โ no guessing the format, no manual renaming of a .txt file to .png. If the string lost its data: header in transit, the signature sniffing still detects the common formats.
Auditing data URI weight in performance work
When a page feels heavy, inlined images are an easy suspect: they inflate the HTML or CSS document itself, so they block first paint instead of loading lazily. Encoding a candidate asset here shows the exact expansion before you commit it to the codebase.
FAQ
Does Base64 encoding change the image quality?
No. Encoding is a reversible text representation of the original bytes, so the decoded file is identical to the source. What changes is size: Base64 uses four characters for every three bytes, which makes the string roughly 33 percent longer than the binary file, and HTML or JSON escaping can add a little more on top.
Why is the Base64 text longer than the image file?
Base64 maps three bytes onto four printable ASCII characters, so the payload grows by about a third by design, and embedding that string in an attribute or a JSON document adds quoting overhead. That is why data URIs suit icons and logos, not multi-megabyte photographs.
Can I decode a string that has no data prefix?
Yes. Paste the bare Base64 body and the decoder inspects the first decoded bytes to detect PNG, JPEG, GIF, WebP, BMP or SVG signatures, then falls back to PNG if nothing matches. Adding the correct header yourself is more reliable when you already know the format.
Is a data URI a good choice for website images?
Only for small assets. Inlining removes one request, but the bytes cannot be cached separately and they are re-sent with every HTML or CSS response that contains them. Use data URIs for icons and email templates rather than hero images or galleries.
Where is my image processed?
Inside this browser tab. The file is read with the FileReader API and converted in JavaScript, and the decoded preview is rendered locally; nothing is posted to a server and there is no upload queue. Output still depends on the source file and your browser build, so verify anything important before publishing it.