Free web tool
Image to Base64
Turn a PNG, JPG, SVG, GIF, WebP or other image into Base64 text: a data URL, the bare string, a CSS background or an HTML img tag, ready to copy. The image is read on your device. Nothing is uploaded.
Bytes of your files sent anywhere: 0
Files are read and converted in this tab, in a background worker. The only requests the page makes are for its own scripts. Your files are never sent anywhere.
How it works
Base64 writes any file as plain letters, digits, + and /, so it can sit inside HTML, CSS, JSON or an email template. The page reads the image's bytes unchanged in a background worker and encodes them, so the picture is exactly the original.
A data URL adds the image's type, such as data:image/png;base64, so a browser can show it from the text alone. The CSS and HTML forms wrap it, ready to paste.
Base64 text is a third larger than the file, and the browser cannot cache it apart from the page, so it suits small icons and images. For large pictures a separate file loads faster.
How to convert Image to Base64
- Pick the output. Data URL for most uses, Base64 only for an API or JSON field, CSS or HTML to paste directly.
- Add the image. Drop the image on the box, click it to choose it, or paste it.
- Copy or download. Use Copy on the row, or download the .txt file.
- Paste it. Put the text where the image would go, such as an img src or a CSS url().
Limits
- Up to 10 MB an image. The Copy button works up to about 2 MB of text; past that, download the file.
- The image is not resized or compressed: shrink it first, for example with PNG to JPG, for a shorter string.
Questions
Are my files uploaded?
What is a data URL?
When should I not use Base64?
Does it change the image?
Is it free?
If this saves you time, you can leave a tip. It helps keep these tools free and online.