Image to Base64
Image to Base64 image data URI encoder PNG to Base64 string JPG inline data URLEncode an image file
Choose a supported local image, select a complete data URL or raw Base64, and encode it. The result includes the detected media type and original byte count. Copy the output or download it as text. Changing the file or output format clears the previous result until you encode again.
Two output forms
Raw Base64 contains only the encoded byte sequence. A data URL adds a prefix such as data:image/png;base64,, which identifies the media type and encoding. Use the full data URL where an application expects a URL, such as an image source. Use raw Base64 where an API field already declares its content type. Adding the prefix twice produces an invalid value.
Worked example: a small PNG
A PNG encoded as a data URL starts with data:image/png;base64, followed by its Base64 characters. A file containing 300 bytes produces 400 Base64 characters before the prefix. A 301-byte file produces 404 characters because Base64 operates in groups of three input bytes and pads the final group. The summary reports the encoded character count separately from the prefix.
Original bytes are preserved
This tool does not redraw the image on a canvas, resize it, strip metadata or change its compression. Animation frames in GIF or WebP files remain part of the encoded bytes. If you need a smaller image, compress or resize the source first, then encode that output. Decoding a copied complete Base64 sequence recovers the original bytes, not a visually similar re-encoded picture.
Recognized formats and limitations
PNG, JPEG, GIF, WebP and AVIF are identified from their file signatures. SVG is checked as an XML document with an SVG root and the SVG namespace. Supported files must be nonempty and no larger than ten megabytes. Signature recognition is not a full integrity check; a damaged image can retain a recognizable header. Renaming an unrelated file does not convert its contents.
SVG content is encoded without rendering or sanitizing it. A valid SVG can contain scripts, links or external references. Only embed files you trust, and apply the restrictions required by the destination application. SVG documents with DOCTYPE or entity declarations are rejected here.
When inline images are a poor fit
Base64 usually increases byte count by roughly one third. Large data URLs can make HTML, CSS or JSON cumbersome and prevent an image from being cached as a separate resource. They are often convenient for a small self-contained asset, a test payload or a system that explicitly requires embedded data. They are not automatically faster than ordinary image files, and they provide no encryption or access control.
Image encoding FAQ
Are my images uploaded?
No. Reading and encoding occur in this browser. The tool does not create a hosted image URL.
Can the existing text Base64 tool do this?
A text encoder handles character encoding. This tool handles arbitrary image bytes and preserves their exact sequence.