Image to Base64 Converter

Convert an image to a base64 data URI — drag, drop, copy the code or download it as text.

100% FreeNo sign-upPrivate — runs in your browser
Drop an image here or click to choose

Your file is read locally in your browser and never uploaded. Base64 output is about 33% larger than the original file.

—

Copied to clipboard

How to use this tool

1
Drop or choose an image

Any image format your browser can read works — JPG, PNG, WebP, GIF and more.

2
Read the data URI

The full data:image/…;base64,… string is ready for HTML, CSS or JSON.

3
Or take the raw base64

The same payload without the data: prefix, for APIs and databases.

4
Download as text

Download .txt saves the base64 for use elsewhere.

Formula & worked example

Base64 groups bytes in threes and represents each group as four characters from A–Za–z0–9+/, padding with = when needed. Encoded length = ceil(bytes / 3) × 4, so output is roughly 33% larger than the input.

The text "hello" encodes to aGVsbG8=; a 3-byte file becomes 4 base64 characters, and a 1,500,000-byte image becomes about 2,000,000 characters.

Limitations — read this before you rely on it

Base64 grows files by about 33%, so large images produce very long strings that can slow a page or exceed field limits — keep base64 embeds small (ideally under ~100 KB). The data URI mime type is taken from the browser’s file type detection.

Frequently asked questions

A way to embed a file directly in code: data:[mime];base64,[payload] — no separate file or URL needed.

It uses 6 bits per character instead of 8 per byte, so the same data needs about 33% more characters.

No — FileReader runs entirely in your browser; nothing leaves your device.

Small icons and single-file HTML emails; for large photos, a real file URL is almost always better.

The encoder accepts any file, but this tool is presented for images; the mime type in the URI comes from the file you choose.