Convert an image to a base64 data URI — drag, drop, copy the code or download it as text.
Your file is read locally in your browser and never uploaded. Base64 output is about 33% larger than the original file.
How to use this tool
Any image format your browser can read works — JPG, PNG, WebP, GIF and more.
The full data:image/…;base64,… string is ready for HTML, CSS or JSON.
The same payload without the data: prefix, for APIs and databases.
Download .txt saves the base64 for use elsewhere.
Formula & worked example
The text "hello" encodes to aGVsbG8=; a 3-byte file becomes 4 base64 characters, and a 1,500,000-byte image becomes about 2,000,000 characters.
Limitations — read this before you rely on it
Base64 grows files by about 33%, so large images produce very long strings that can slow a page or exceed field limits — keep base64 embeds small (ideally under ~100 KB). The data URI mime type is taken from the browser’s file type detection.
Frequently asked questions
A way to embed a file directly in code: data:[mime];base64,[payload] — no separate file or URL needed.
It uses 6 bits per character instead of 8 per byte, so the same data needs about 33% more characters.
No — FileReader runs entirely in your browser; nothing leaves your device.
Small icons and single-file HTML emails; for large photos, a real file URL is almost always better.
The encoder accepts any file, but this tool is presented for images; the mime type in the URI comes from the file you choose.
