Upload a file
  1. base64hub
  2. Image tools
  3. Favicon to data URI

Favicon and ICO to Base64

Drop a favicon.ico, PNG or SVG and paste the data URI into <link rel="icon">. Useful for single-file pages, internal tools and favicons generated on the fly.

Free no sign-up, no limits Local nothing uploaded Updated Oct 27, 2026
Drop an image here, paste one, or pick it
Input –Output –Size –

Processed in your browser. This page cannot send your data anywhere – how we know

How to convert a favicon to Base64

  1. Drop favicon.ico, a PNG or an SVG on the box, or pick it with the file picker.
  2. For a PNG, set Max width to 32 (or 48) so you do not inline a 512-pixel app icon by accident. ICO and SVG files are encoded as they are.
  3. Output as is set to Data URI. Copy it and paste it into the href:
<link rel="icon" type="image/png" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUg...">

The preview shows the icon with its pixel size, so you can see whether a PNG is really 32×32 before you paste it.

ICO, PNG or SVG

FormatMIME typeBase64 starts withNotes
ICOimage/x-iconAAABAAcan hold several sizes in one file; every one is inlined
PNGimage/pngiVBORw0KGgoone size per file, small at 32×32
SVGimage/svg+xmlPHN2Zyscales to any size; Safari only from version 26

A favicon.ico often bundles 16×16, 32×32 and 48×48 images, and all of them end up in the Base64, which explains a string longer than you expected. Converting a single 32×32 PNG is usually enough for a browser tab.

SVG favicons can react to dark mode with a prefers-color-scheme media query inside the SVG. Keep a PNG as a fallback if you support older Safari.

When an inline favicon makes sense

  • Single-file HTML: exported reports, offline docs, a dashboard saved as one file. A relative favicon.ico path would point nowhere once the file is moved.
  • Internal tools and local servers where adding a static file route is more work than one line of HTML.
  • Dynamic favicons: a notification badge or status color drawn on a canvas and applied with link.href = canvas.toDataURL("image/png").

On a normal website a separate icon file is the better choice. The browser fetches and caches it once, while an inline favicon is repeated in every HTML page you serve.

Drawing a favicon in JavaScript

For a status indicator you do not need a file at all. Draw on a 32×32 canvas and assign the data URI to the existing icon link:

const canvas = document.createElement("canvas");
canvas.width = canvas.height = 32;
const ctx = canvas.getContext("2d");
ctx.fillStyle = "#e33";
ctx.beginPath();
ctx.arc(16, 16, 14, 0, Math.PI * 2);
ctx.fill();
document.querySelector('link[rel="icon"]').href = canvas.toDataURL("image/png");

When the icon does not change

  • The old icon keeps showing. Browsers cache favicons hard and separately from the page. Reload without cache or open the page in a private window to see the new one.
  • Nothing shows at all. Check that the href starts with the right type: data:image/png;base64,, data:image/x-icon;base64, or data:image/svg+xml;base64,. An SVG icon also needs the xmlns attribute on its root element.
  • Several <link rel="icon"> tags. Browsers choose among them by type and size, so an inline icon may lose to another declared icon. Remove the ones you do not want.

Turning it back into a file

To get favicon.ico back from a data URI, use Base64 to ICO. For SVG icons, SVG to Data URI can also produce a URL-encoded version, which is often shorter than Base64.

FAQ

Can a favicon be a Base64 data URI?

Yes. Put the data URI in the href of <link rel="icon">, for example href="data:image/png;base64,iVBORw0KGgo...". Browsers treat it like any other icon URL.

Which MIME type should a Base64 ICO use?

image/x-icon is the most widely used; image/vnd.microsoft.icon is the registered name. Browsers accept both. The tool uses whichever type your browser reports for the file.

Do SVG favicons work in all browsers?

Chrome and Edge support them from version 80, Firefox from 41 and Safari from 26. If you still need older Safari versions, add a PNG icon next to the SVG one.

How do I stop the browser requesting /favicon.ico?

A common trick is an empty data URI: <link rel="icon" href="data:,">. It gives the page no icon at all, which is handy for test pages and local tools.