What Image to Base64 Converter Does
Encodes an image file as Base64 text and gives it to you as a data URI, raw Base64, an HTML img tag, a CSS background-image rule, or a Markdown image. A second tab does the reverse: paste Base64 or a data URI and get the image back as a file.
Step-by-Step Instructions
- On the Image → Base64 tab, drop an image (up to 10 MB).
- Choose the output style: Data URI, Raw Base64, HTML, CSS, or Markdown.
- Press Copy to Clipboard, or Download .txt for very long strings.
- To go the other way, open Base64 → Image, paste the text, press Decode to Image, and download the file.
How It Works in Your Browser
Encoding reads the original bytes of the file and converts every three bytes into four text characters from a 64-character alphabet. The file is not decoded or recompressed, so the image you get back from the text is byte-for-byte the file you put in. Decoding strips any data URI prefix and whitespace, accepts both standard and URL-safe alphabets, converts the text back to bytes, and identifies the image type from the file signature in those bytes.
Quality Considerations & Common Mistakes
Inlining suits small images: icons and simple logos up to a few kilobytes. Above roughly 100 KB the costs outweigh the saved request: the browser cannot cache the image separately, the HTML or CSS that contains it grows by a third more than the image’s size, and the page takes longer to parse. Compress or resize the image before encoding, since every byte saved in the file saves 1.33 characters of text.
- Pasting raw Base64 into an img src without the “data:image/png;base64,” prefix, which shows a broken image.
- Inlining large photos into CSS, which blocks rendering until the whole stylesheet has downloaded.
- Assuming Base64 hides or protects an image. It is an encoding, not encryption; anyone can decode it.