Image to Base64 Converter
ED-69Open an image file and get its Base64 text, either as a data URI or as plain Base64. The same result can be wrapped as a CSS background-image rule, an HTML img tag or a Markdown image.
Runs in your browser. Nothing is uploaded.
Image file
Base64
How to use it
- Drop an image on the left box or press Open file. PNG, JPG, GIF, WebP, BMP, ICO, AVIF and SVG files are recognized.
- Choose the output: Data URI, Base64 only, CSS background-image, HTML img tag or Markdown image.
- For Base64 only, pick a line length if the place you paste into wants wrapped lines.
- Check the preview and the size line, then press Copy or Download.
What you get from each output choice
Data URI starts with data: and the image type, for example data:image/png;base64, followed by the Base64 text. You can paste it into an img src, a CSS url() or a JSON field. Base64 only drops that prefix, which is what some APIs and config files expect. The CSS choice writes a background-image rule with the URI in quotes. The img choice adds the pixel width and height read from the file, and an empty alt attribute you should fill in if the picture carries meaning.
The picture is encoded as it is, not changed
The tool reads the file's bytes and turns them into Base64 without decoding the picture. Nothing is resized, recompressed or cleaned, so the image looks the same and any metadata, such as camera details or a GPS location in a photo, is still inside the text. If that matters, strip the metadata from the file first. The type is read from the first bytes of the file, so a PNG that was renamed .jpg still gets image/png.
When a data URI is a good idea
Base64 makes the data about a third larger than the file, and a data URI becomes part of the page or style sheet that contains it, so the browser cannot cache it on its own. That suits small icons, placeholders and email-safe snippets. For a large photo a normal image file is usually the better choice. This tool refuses files over 10 MB so the text box stays usable.
Error messages and what to do
| Message | What it means | Fix |
|---|---|---|
The file is empty. | The file has zero bytes. | Pick a different file, or re-export the image. |
This does not look like an image. Its first bytes match this type: … | The file starts like a PDF, ZIP, plain text or another non-image format. | Open the actual image file. For SVG code, use the SVG to Base64 converter. |
This file is not recognized as an image. It starts with the bytes … | The first bytes match no known image format and the file name has no image extension. | Check that the file is a picture, or rename it with its real extension such as .png. |
Questions people ask
How do I convert an image to Base64?
Drop the image on the box or press Open file. The Base64 text appears at once, and you can pick data URI, Base64 only, a CSS rule, an img tag or a Markdown image. Press Copy to put it on your clipboard.
What is the difference between Base64 and a data URI?
Base64 is only the encoded text. A data URI adds a prefix such as data:image/png;base64, in front, so a browser knows the type and can use it as an image address. Use the data URI for src and url(), and plain Base64 where an API asks for the raw string.
Why is the Base64 text bigger than my image?
Base64 writes every 3 bytes as 4 characters, so the text is about 33% larger than the file. The size line under the preview shows the exact count for your file. The image data itself is not changed.
Which image types does it accept?
PNG, JPEG, GIF, WebP, BMP, ICO, AVIF, SVG, TIFF and HEIC are recognized from the file content. A rare format is accepted by file name only. Whether your browser can show the preview depends on the format, but the Base64 output is correct either way.
Is there a size limit?
Yes, 10 MB per file. A larger file would give a text about 13 MB long, which is too heavy for a text box and rarely a good idea in a page. Compress or resize the image first, or serve it as a normal file.
Can I get the image back from the Base64?
Yes. Paste the data URI or the Base64 text into the Base64 to Image converter on this site. It detects the file type from the data and gives you the original file to download.
About this tool
Reads the file in your browser and writes its bytes as Base64 exactly as they are. The picture is not re-encoded, resized or cleaned, so metadata such as camera details or location stays inside the Base64 text. The type comes from the first bytes of the file (PNG, JPEG, GIF, WebP, BMP, ICO, AVIF, SVG, TIFF, HEIC) and only falls back to the file name when the bytes are not recognized. Files over 10 MB are refused because the text would be a third larger and too heavy for a text box. A data URI becomes part of the page or style sheet that holds it, so the browser cannot cache it on its own. Line breaks apply to the Base64 only output.