/tools/image-to-base64

Image to Base64

Encode a JPG, PNG, WebP, GIF or SVG as Base64 text you can paste into code, JSON or a template. Choose plain Base64, a data URI, a CSS rule or an HTML tag.

Private & secure
Upload image or drag & drop
JPG · PNG · WebP · GIF · SVG

How to use the Image to Base64

01
Upload
Drop an image.
02
Choose output
Plain Base64, a Data URI, CSS or an HTML tag.
03
Copy
Copy to clipboard or download as a text file.

What Base64 encoding does

Base64 turns binary data into plain text made of 64 safe characters: A to Z, a to z, 0 to 9, plus and slash. Every 3 bytes of the image become 4 characters, so the encoded text is about a third larger than the file. The panel under the preview shows the original size, the encoded size and the overhead as a percentage.

The encoding is done by your browser using the file you select. Nothing is sent to a server, which makes it suitable for internal screenshots and other images you would rather not upload.

Choosing an output format

Base64 gives the bare string, which is what most APIs and JSON fields expect. Data URI adds the data:image/...;base64, prefix so the string can be used directly as an image address. CSS wraps it in a background-image rule, and HTML wraps it in an img tag with an empty alt attribute for you to fill in.

Use Copy to put the result on your clipboard or Download .txt to save it; the file is named after the output you chose, such as photo-data-uri.txt or photo-css.txt. Very long outputs are cut short in the preview box only; Copy and Download always give the complete text.

When embedding an image as Base64 makes sense

Base64 is handy for small icons and logos inside a single HTML file, for sending an image through an API that only accepts JSON, for test fixtures and for storing small images in a text field. It is a poor fit for large photos: the text is bigger than the file, it can't be cached separately by the browser, and it bloats every page or document that contains it. Many email clients also block images embedded this way, so test before relying on it in a newsletter.

Supported formats

JPGPNGWebPGIFSVG

Files up to 25 MB. Large, high-resolution photos are supported.

Privacy

This tool runs entirely in your browser. Your image is never uploaded. No account needed. How we handle files.

Image to Base64 FAQ

Why is the Base64 string larger than the image?

Base64 uses 4 text characters for every 3 bytes, adding roughly 33% to the size.

What is the difference between Base64 and a data URI?

A data URI is the Base64 string with a prefix that states the type, such as data:image/png;base64,. Browsers can use a data URI as an image source directly.

How do I turn Base64 back into an image?

Paste it into Base64 to Image, which previews the picture and lets you download it.

Is Base64 a form of encryption?

No. Anyone can decode it instantly. It is an encoding for moving binary data through text, not a way to hide it.

Is there a size limit for encoding?

The work happens on your device, so the practical limit is your browser's memory. Keep in mind that a 5 MB photo becomes almost 7 MB of text.

Are my images safe?

This tool runs entirely in your browser. Your image is never uploaded.

Is it free?

Yes. No account, no watermark and no limit on how many images you process. Files can be up to 25 MB.

Related tools

See all 8 utilities tools →