When to Embed an Image as Base64 (And When Not To)

A data URL puts a whole image inside your HTML or CSS. Great for tiny icons, terrible for photos. How to decide, and how to generate one free in your browser.

Updated 2026-11-17 · 1 min read

What a data URL is

A Base64 data URL is your image written as text. Paste it into an img tag or a CSS rule and the browser shows the image without asking a server for a file. One request fewer, per page load, per icon.

When it is worth it

Use it Skip it
Small icons and badges Photos
Logos on every page Anything over 100 KB
Images in a single-file HTML Emails (many clients block them)
Backgrounds in CSS themes Images that change often

Base64 makes a file about a third bigger than its binary form. On a small icon that cost is nothing next to a saved network request. On a photograph it slows the page down for no benefit.

Quick steps

  1. Open the image to Base64 tool.
  2. Drop the image in. The size cost shows straight away.
  3. Copy the data URL, the raw Base64, or the ready-made HTML and CSS.

The forms you can copy

The tool gives all four, so you never hand-edit:

  • The full data URL, for src attributes
  • Raw Base64, for JSON payloads and APIs
  • A ready <img> tag
  • A ready CSS background-image rule

Watch the cache

A normal image file is cached by the browser on its own. A data URL rides inside the HTML, so it re-downloads with every page load. That is the trade: fewer requests, but no separate caching. Icons used on every page are the sweet spot.

Making the icon first

Turning a logo into a favicon-sized icon? SVG to ICO makes the favicon file, and the Base64 tool embeds a copy where a file request is not wanted.


Found this useful? Browse the free tools or suggest the next guide.