Comparison

Base64 vs Plain Image Files: What's Faster and When

The same logo can be wired up two ways: as a link to a file, logo.png, or as a string baked into the code, data:image/png;base64,…. It seems trivial, but the two options affect site speed differently. Let's compare them honestly — on size, cache and request count — and give a simple answer on which to pick.

A green Matrix-style stream of digits — data as a flow
File or string — two ways to deliver the very same image bytes. Photo: Pexels

Two ways to wire up an image

First, an important point: these are not two different image formats. Both the file and the Base64 string hold the exact same image bytes. Only the delivery differs. A file is a separate resource on the server that the browser fetches by link. Base64 is the same data rewritten as text and pasted straight into the HTML or CSS.

If you want to refresh exactly how the encoding works, see "What is Base64." Here we'll run an honest comparison of the two approaches across three key metrics.

<!-- Option 1: a link to a file -->
<img src="/img/logo.png">

<!-- Option 2: the same data as a Base64 string -->
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUg...">

Spoiler

There is no universal winner. The file wins on size and cache; Base64 wins on request count for tiny things. So the question isn't "which is better overall," but "which is better for this particular image."

Round 1: size — the file wins

This one is clear-cut. Base64 doesn't compress data, it only rewrites it as text, and because of the "3 bytes → 4 characters" scheme the string ends up about 33% bigger than the original file. A 9 KB image as Base64 takes up roughly 12 KB.

So on raw weight the separate file is always lighter. And the larger the image, the more noticeable that difference becomes in absolute kilobytes.

It's worth busting a common myth here: "but the server compresses Base64 on the way out, so there's no difference." Compression does claw back part of the bloat, but not all of it — the squeezed-down text is still heavier than the squeezed-down file, and the browser has to do extra work unpacking it on top. So treating Base64 as "free" is a mistake.

Colourful code close-up on a dark screen — data and its representation
Same bytes, two representations: a compact file or a text string a third longer. Photo: Pexels

Round 2: request count — Base64 wins

Here Base64 has its single but important trump card. A separate file requires a separate HTTP request: the browser has to open a connection and fetch the resource. A Base64 image arrives with the HTML or CSS, so there's no extra request at all.

In the early web, on HTTP/1.1, this was decisive: dozens of small files genuinely slowed loading. But modern HTTP/2 and HTTP/3 carry many files over a single connection at almost no overhead — and Base64's advantage here has faded a lot. More on that in "Base64 images on the web."

The nuance

The request win only matters for very small images. Saving one request at the cost of an extra 33% is worth it on a 1 KB icon and utterly not worth it on a 500 KB photo.

Round 3: caching — the file wins decisively

This is the deciding round. The browser downloads a separate file once and then serves it from cache — across other pages and on repeat visits. One icon used on 20 pages downloads exactly once.

A Base64 string is baked into the HTML or CSS, so it has no cache of its own: it loads again with the page on every request. The same icon across 20 pages means 20 downloads of identical data. On a site with returning visitors, the file wins by a huge margin.

A file downloads once and lives in the cache. A Base64 string pays for itself on every single page load.
A corridor of glowing digits — a stream of repeatedly downloaded data
With no cache, embedded data has to be "carried" anew on every page. Photo: Pexels

The summary table

Let's put it all in one place:

CriterionBase64Plain file
Data size+33%smaller
Separate HTTP requestnonerequired
Cached separatelyNoYes
Appears instantlyYesafter load
Easy to swap/editHardEasy
Good for large photosNoYes
+33%Base64 size
−1request with Base64
file load from cache

What to choose in practice

The takeaway is simple, no fluff:

  • Plain file — by default. It's smaller, cacheable and easy to update. It's the right choice for the vast majority of images: photos, banners, illustrations, anything that appears on more than one page.
  • Base64 — surgically. For tiny icons up to ~5 KB that must appear instantly; for critical CSS; for logos in HTML emails. Here the saved request and guaranteed appearance outweigh the size growth.

It's not either/or, but two tools for different jobs. We break down exactly which scenarios justify Base64 in "Base64 in CSS and email."

A small real-world example

Say you run an online store. The header logo appears on every page — so its place is a separate file: it caches once and works site-wide. But a tiny checkmark icon in an "Added to cart" button, which must flash instantly the moment you click, is a great candidate for Base64 in CSS: one saved request matters more than an extra kilobyte. Product photos, of course, are always separate files — they're large, cacheable and often reused across the catalog.

See the logic? The decision isn't made "in general," but per image — by its size, how often it shows, and how urgently it's needed on screen.

Need to turn an image into Base64?

Encode a PNG to a string online, or do the reverse — our converter works both ways, right in the browser and with no install.

Convert PNG to Base64

The reverse direction is Base64 → PNG, and the full list of converters is on the all formats page.

The plain file. Base64 does not compress the data, it only rewrites it as text, which makes the string about 33% bigger than the original file. So on raw size, the file always wins.
For one thing: removing a separate HTTP request and embedding the image straight into text — HTML, CSS, JSON or an email. That is handy for tiny icons, critical CSS and email. In every other case a separate file is more practical.
A separate file, by a wide margin. The browser downloads it once and reuses it across all pages and on repeat visits. A Base64 string is baked into the HTML or CSS and loads again on every page request — it has no separate cache of its own.
Yes, a lot. If one icon is used across many pages, the file caches once and wins. If a set of unique icons appears on a single screen and is needed instantly, embedding as Base64 saves a few requests.
By default, use plain files: they are smaller and cacheable. Reach for Base64 surgically — for small icons under 5 KB, critical CSS and HTML emails. It is not either/or, but two tools for different jobs.