Image to Base64

Fetch an image Uniform Resource Locator (URL) and convert it to a Base64 data Uniform Resource Identifier (URI) for embedding directly in Cascading Style Sheets (CSS) or HyperText Markup Language (HTML).

Max 512 KB. Supports JPEG, PNG, GIF, SVG, WebP, etc.

What the data URI looks like

A data URI carries the file inside the address. It has a fixed structure:

data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA...
     └───┬───┘ └──┬─┘ └──────────┬──────────────┘
     media type  encoding      the file, Base64-encoded

The start of the Base64 text identifies the format, because every image format begins with fixed bytes:

iVBORw0KGgo   PNG
/9j/          JPEG
R0lGOD        GIF
UklGR         WebP
PHN2Z         SVG that begins with <svg

Use the result as the src of an <img> element or inside url(...) in a stylesheet.

When inlining an image helps and when it hurts

  • Size grows by one third. Base64 writes 3 bytes as 4 characters: a 30 kB image becomes 40 kB of text. Compression of the page recovers part of that, not all.
  • No separate caching. An inlined image is downloaded again with every page or stylesheet that contains it. A normal image file is fetched once and reused from the cache.
  • It blocks rendering in CSS. A stylesheet must be downloaded completely before the page is drawn. Large inlined images delay the first paint of the whole page.
  • Where it is useful. Icons and placeholders of a few kilobytes, images in HTML email signatures, and single-file documents that must work without a server.

As a working limit, inline images below about 4 kB and serve everything larger as a file. For an SVG, the markup can also be placed in the page directly, which is smaller than its Base64 form.

Related tools

Monitor Image to Base64 automatically

Fetch an image Uniform Resource Locator (URL) and convert it to a Base64 data Uniform Resource Identifier (URI) for embedding directly in Cascading Style Sheets (CSS) or HyperText Markup Language (HTML). NetTests can run this check on a schedule, preserve historical results, compare changes over time, and alert you the moment something breaks.

Start monitoring free → See all monitoring products

Frequently Asked Questions

What is a Base64 data URI for images?

A data Uniform Resource Identifier (URI) embeds file content directly in HyperText Markup Language (HTML) or Cascading Style Sheets (CSS) as a Base64-encoded string: data:image/png;base64,iVBOR.... This eliminates an HyperText Transfer Protocol (HTTP) request for the image. Common uses: small icons in CSS (to avoid extra requests), email HTML (many clients block external images but render embedded ones), and self-contained single-file HTML documents.

When should I use inline Base64 images?

Best for small images (icons, logos under ~2–3 KB) where the Base64 overhead is outweighed by saving an HyperText Transfer Protocol (HTTP) round-trip. Avoid it for large images — Base64 encoding increases file size by ~33%, and the encoded data can't be cached separately by the browser. For most production images, a Content Delivery Network (CDN)-served image with proper caching headers is preferable.

How do I use the output in CSS?

background-image: url('data:image/png;base64,iVBOR...'); — paste the full data Uniform Resource Identifier (URI) as the url() value. In HyperText Markup Language (HTML): <img src="data:image/png;base64,...">. The data URI must include the data:image/...;base64, prefix, which this tool includes automatically.