Convert Image to Base64 String

Encode any image as a Base64 data URI for use in HTML, CSS, JSON, or email. Free, private, instant โ€” no upload needed.

๐Ÿ”’

Your images never leave your device

Base64 encoding is done locally using the browser's FileReader API. Nothing is uploaded.

๐Ÿ”ข

Drop an image here

or click to browse โ€” JPG, PNG, WebP, SVG, GIF accepted

JPG PNG WebP SVG

About Base64

Base64 encodes binary image data as ASCII text, making it safe to embed in HTML, CSS, JSON, XML, or email without file attachments.

Data URI format:

data:[mime];base64,[data]

โš ๏ธ File size note

Base64 encoding increases file size by ~33%. Use it for small icons and logos, not large photos.

When to use Base64 image encoding

Base64 encoding converts binary image data into a text string that can be embedded directly into code. This eliminates the need for a separate image file and the HTTP request to fetch it, which can improve performance for small, frequently-used images.

Common use cases: embedding small icons or logos in CSS (saves one HTTP request per icon), inlining images in HTML emails (many email clients block external images), embedding images in JSON API responses, data URIs in SVG files, and testing with image data without needing a file server.

When not to use it: Base64 encoding increases data size by approximately 33% compared to the binary file. For large photos, this overhead is significant โ€” use a regular image URL instead. Base64 is best for images under 10KB.

Frequently asked questions

What is the difference between a data URI and a base64 string?

A data URI is the full string including the MIME type prefix: data:image/png;base64,iVBOR.... The base64 string is only the encoded data part after the comma. Use the full data URI in src attributes and CSS; use the raw base64 string when an API expects it without the prefix.

Can I decode base64 back to an image?

Yes โ€” in a browser, paste the data URI into an img src and the browser renders it. Most programming languages have built-in base64 decode functions: atob() in JavaScript, base64.b64decode() in Python.

Is my image private?

Yes. The FileReader API reads your file locally โ€” no data is sent anywhere. The base64 string is generated entirely in your browser's memory.

Why does base64 output look random and very long?

Base64 represents every 3 bytes of binary data as 4 ASCII characters. An average 50KB PNG becomes ~67KB of base64 text โ€” which is why it looks long. This is expected behavior.

Related tools

๐Ÿ—œ๏ธ Compress Images

Reduce size before encoding

PNG โ†’ JPG

Smaller file for base64 embedding

๐Ÿ”„ Format Converter

Convert to optimal format first