Image to Base64 Converter

Encode images to Base64 strings or decode Base64 back to images — instantly in your browser.

Drop your image here

or click to browse

JPG, PNG, WebP, GIF, SVG

How to Use

1

Choose a Tab

Select "Image → Base64" to encode an image file, or "Base64 → Image" to decode a Base64 string back into a viewable image.

2

Upload or Paste

For encoding: drag and drop your image or click to browse. For decoding: paste your Base64 string (with or without the data URL prefix) into the text area.

3

View the Result

The Base64 string or decoded image preview appears instantly. Character count and file size are shown for encoded results.

4

Copy or Download

Click Copy to copy the Base64 string to your clipboard, Download .txt to save it as a text file, or Download Image to save the decoded image.

Image to Base64 — Encode Images for Direct Embedding in Code

Base64 is a way to represent binary data — like an image file — as plain text characters. An image encoded as Base64 is a long string of letters and numbers that any text-based system can store, transmit, or embed. The practical use: you can embed an image directly in HTML, CSS, or JavaScript without needing a separate image file. Instead of linking to an image URL, you embed the entire image as a data URI directly in your code.

This tool converts any image you upload into its Base64 string. Copy the output and use it directly in your code, email templates, SVG files, or anywhere that needs an image without a URL.

How to Use It

Upload your image. The tool immediately encodes it and displays the Base64 string in the output area. The string is formatted as a data URI — it starts with data:image/png;base64, (or jpeg, webp, etc.) followed by the encoded data. Click to copy the entire string. Paste it directly as the src attribute of an <img> tag, or as a CSS background-image URL value.

When Base64 Embedding Is Useful

Small icons and UI elements in CSS: Small icons embedded as Base64 in CSS eliminate an HTTP request for each icon file. For icons under 2–5KB, embedding reduces the number of requests the browser needs to make, which can marginally improve load time. This is the most common legitimate use of Base64 images in production code.

Single-file HTML documents: If you're creating a self-contained HTML document that must work without external files — an offline page, a report saved as a single .html file, an email template — embedding images as Base64 means the images are part of the HTML file itself. Open the file anywhere and the images display, even without internet access.

Email HTML: Email clients are notoriously inconsistent about loading external images (many block them by default). Embedding small images as Base64 in HTML email templates means they display regardless of whether the email client allows external images to load. Note: very large Base64 images increase email file size significantly, which some email providers penalise.

API payloads: Some APIs accept image data as a Base64 string in a JSON payload, rather than as a file upload. Converting your image to Base64 here gives you the string you need to include in the API request body.

Canvas and SVG embedding: JavaScript canvas operations sometimes require image data as a data URI. SVG files can embed raster images as Base64 to create self-contained vector files.

Testing and prototyping: When you're prototyping a design and don't want to deal with hosting image files, embedding as Base64 in your HTML lets you work self-contained without a web server.

When NOT to Use Base64

Base64 encoding increases file size by approximately 33% compared to the original binary. A 100KB image becomes around 133KB as a Base64 string. For large images embedded directly in HTML or CSS, this means larger page downloads. For large images in HTML, use a regular image URL — the browser can cache external images effectively, but Base64 strings embedded in HTML or CSS are re-parsed every time. Base64 makes sense for small images where the elimination of an HTTP request outweighs the size increase. For anything above a few kilobytes, link to the image file instead.

Privacy and Limitations

Encoding happens entirely in your browser — the image is not uploaded anywhere. Very large images produce very long Base64 strings — some text editors and browser input fields struggle to handle strings of several megabytes. For images larger than 50–100KB, consider whether Base64 embedding is actually appropriate for your use case, or whether linking to the image file would work better.

Frequently Asked Questions

Base64 encoding converts binary image data into a text string made up of ASCII characters. This allows images to be embedded directly inside HTML, CSS, JSON, or other text-based formats without needing a separate image file.

Yes. The output includes the full data URL (e.g. data:image/png;base64,...) which you can use as an src attribute in an <img> tag or as a background-image value in CSS. This is useful for small icons or when you want to avoid extra HTTP requests.

Yes. Base64 encoding increases the data size by approximately 33%. A 100 KB image becomes roughly 133 KB as a Base64 string. This is a trade-off for the convenience of embedding images inline in text documents.

Any image format your browser supports can be encoded, including JPG, PNG, WebP, GIF, and SVG. The resulting data URL preserves the original MIME type. For decoding, any valid Base64-encoded image data URL is supported.

No. All encoding and decoding is done entirely in your browser using the FileReader API and JavaScript. Your images and Base64 strings never leave your device.