Image to Base64 Converter

By Asira Tools Team · Last updated 20 November 2026

Encode an image as a Base64 data URL — ready to paste into HTML, CSS, or JSON — and see exactly how much bigger the encoding makes it.

Advertisement

Image to Base64 Converter

Drop an image here

or click to choose a file from your device

Choose an image to begin
Original size—
Encoded size—
Overhead—
Data URL prefix—

The encoding runs in your browser with FileReader — your image never leaves your device.

Formulas:

Encoded length = 4 × ceil(bytes ÷ 3)

Overhead ≈ 33.3% — every 3 bytes of image become 4 characters of text

What Is Base64?

Base64 is a way of writing binary data — the raw bytes of an image, a font, or any file — using only 64 safe text characters: the letters A to Z, a to z, the digits 0 to 9, plus (+) and slash (/), with equals (=) as padding at the end. It was defined in RFC 4648 and has been a workhorse of the internet for decades, because so many systems only handle text reliably: email bodies, JSON, HTML attributes, CSS files, and URLs all prefer plain characters to raw bytes.

The idea is simple. Binary data is made of bytes, each holding 8 bits. Base64 regroups those bits into chunks of 6, and each 6-bit chunk maps to one of the 64 characters. Three bytes (24 bits) become exactly four characters, which is why Base64 output is always about a third larger than the input. Nothing is lost in the process: decoding reverses the mapping exactly, byte for byte. Base64 is an encoding, not compression and not encryption — anyone can decode it, and it is never a way to hide or protect data.

How to Use This Converter

Drop an image onto the drop zone, or click it to choose a file. The tool reads the file and encodes it immediately, in your browser — the image never leaves your device. You will see the original size, the encoded size, and the overhead (how many extra bytes the encoding adds), plus the data URL prefix for your image type, such as data:image/jpeg;base64, for a JPG.

The text box shows the first 200 characters of the data URL so you can confirm the format at a glance. The full string is usually far too long to display — a single phone photo encodes to roughly two million characters — so use the Copy button to put the whole data URL on your clipboard, or the Download button to save it as a .txt file. A small preview of the image appears below, confirming that the file was read correctly.

The Base64 Formula

The length of a Base64 string follows directly from the 3-bytes-to-4-characters rule: encoded length = 4 × ceil(bytes ÷ 3). The ceiling matters when the byte count is not a multiple of three — the last group is padded with = characters to complete it. So 3 bytes encode to exactly 4 characters, 100 bytes encode to 136 characters (4 × ceil(100 ÷ 3) = 4 × 34), and the overhead works out to about 33.3% in every case, plus at most two padding characters.

Here is a worked example with a real photo. A JPG of 1,500,000 bytes (about 1.43 MB) encodes to 4 × ceil(1,500,000 ÷ 3) = 4 × 500,000 = 2,000,000 characters. The overhead is 500,000 characters — exactly one third more than the original. Add the data URL prefix (23 characters for data:image/jpeg;base64,) and the full string you paste is 2,000,023 characters long. This tool shows you exactly these numbers for your own file, so there are no surprises when you paste the result into a document.

What Is a Data URL?

A data URL is a complete file packed into a single string, in the form data:[media type];base64,[encoded data]. Instead of pointing at an image on a server, it contains the image itself. You can paste one straight into an HTML img tag — <img src="data:image/png;base64,..."> — and the browser will render it without making any network request. The same trick works in CSS, as a background-image value, and anywhere else a URL is accepted.

Data URLs are supported by every modern browser, and they have some genuine advantages. An HTML email with embedded images displays even when the reader is offline, because nothing needs to be fetched. A single-file HTML report with its charts embedded can be sent as one attachment and will always look right. And a small icon embedded in CSS saves a network request, which on a slow connection is a real performance win. But the technique has limits, and knowing them is what separates a good use from a bad one.

When to Use Base64 — and When Not To

Base64 shines for small images: icons, logos, tiny badges, and small decorative graphics under about 10 KB. At that size the 33% overhead is a few kilobytes, and saving a network round trip is worth far more. It is also the right choice when a file must travel through a text-only channel — inside a JSON API payload, an email body, or a configuration file — where raw bytes simply cannot go.

It is the wrong choice for large images. A 2 MB photo becomes a 2.7 MB string, which bloats the HTML file containing it, cannot be cached separately by the browser, and cannot be lazy-loaded — the browser must download the whole page before it can show anything. A page with several embedded photos can easily reach tens of megabytes and feel sluggish on a phone. For photographs and anything over a few dozen kilobytes, link to the image file instead and let the browser cache it normally.

A good rule of thumb: if the image is smaller than about 10 KB and it is needed on every page load, embed it. If it is a photo, a screenshot, or anything a user might want to save separately, keep it as a file. And never embed an image in a page that is itself cached aggressively — when the image changes, every cached copy of the page goes stale with it.

Tips for Working With Base64

Keep the prefix. The data:image/png;base64, part at the front tells the browser what kind of file the string is. Paste the whole string, prefix included — without it, the browser does not know how to interpret the characters and the image will not render.

Watch the quotes. In HTML, the data URL sits inside an attribute value, so it must be wrapped in quotes like any other URL. In CSS, wrap it in url("..."). A missing quote is the most common reason an embedded image silently fails to appear.

Prefer the Download button for big strings. A clipboard holding two million characters can be slow to paste into some editors, and a stray edit in the middle will corrupt the image. Saving the .txt file gives you a clean copy you can open, search, and copy from in pieces.

Compress the image first. Base64 cannot make a file smaller, so shrink the image before encoding it: resize it to the dimensions it will actually display at, and save photos as JPG rather than PNG. A 200 KB photo resized to 40 KB encodes to about 53 KB instead of 267 KB — the same picture on screen, a fifth of the weight.

Common Mistakes to Avoid

The biggest mistake is treating Base64 as encryption. It is not: anyone who sees the string can decode it in seconds, and there are decoders built into every programming language. Never Base64-encode a password, a secret key, or anything sensitive and call it protected. Encoding is about transport, not security.

The second mistake is forgetting the overhead. A page that embeds ten 100 KB images is not a 1 MB page — it is a 1.33 MB page, and the browser has to parse all of it as text before it can render anything. Measure the encoded size (this tool shows it) and compare it against simply linking the files.

Finally, do not edit the string by hand. A single changed character in the middle shifts every byte after it, and the image will decode as garbage or not at all. If the string looks wrong, re-encode the image rather than trying to fix the text. And if the image you want to encode is a HEIC photo from an iPhone, convert it first with the HEIC to JPG Converter — browsers cannot display HEIC data URLs at all.

Advertisement

Frequently Asked Questions

How much bigger does Base64 make an image?

About 33.3% bigger. Every 3 bytes become 4 characters, so a 1,500,000-byte JPG encodes to 2,000,000 characters. The data URL prefix adds a few more characters on top.

Is Base64 encryption?

No. Base64 is an encoding, not encryption — anyone can decode it instantly. It exists to carry binary data through text-only systems like JSON, email, and HTML, not to hide or protect data.

Can I paste a data URL into HTML?

Yes. Paste the whole string, prefix included, as the src of an img tag, for example <img src="data:image/png;base64,...">. Every modern browser renders it without a network request.

Why is my Base64 string so long?

Because it contains the entire image as text. A single phone photo of 1.5 MB encodes to about 2 million characters, which is why this tool shows the first 200 characters and lets you copy or download the full string.

When should I not use Base64 for images?

For large images. Photos and anything over a few dozen kilobytes are better linked as files, because embedded data URLs bloat the page, cannot be cached separately, and cannot be lazy-loaded. Base64 is best for small icons and graphics under about 10 KB.