zerouploads

Image to Base64 Converter

Turn an image into a Base64 data URI you can paste straight into CSS, HTML or JSX.

  • Unlimited
  • No signup
  • Private
  • Works offline

Image to Base64 workbench

No image yetdrop or choose an image to start

Choose an image file

Source

——

Data URI

The data URI appears here once you add an image.

——

Output settings

Bare Base64 only: a newline breaks a data URI.

Code snippet

​

How it works

  1. 01

    Drop an image

    PNG, JPG, SVG, WebP, GIF, AVIF or ICO. The bytes are copied as they are, so transparency and animation survive.

  2. 02

    Pick the shape

    A full data URI, the bare Base64, or a CSS url(). Add quotes and line wrapping if your file needs them.

  3. 03

    Paste it in

    Copy the value, or the ready-made CSS, HTML, JSX or Markdown snippet below it.

When inlining is worth it

Every inlined image saves one request. That mattered more before HTTP/2, which fetches many files down one connection. The clear wins now are small assets that would otherwise hold up first paint. An icon in critical CSS is one.

Above about 4 kB, inlining usually costs more than it saves. Base64 is a third larger than the file, and the browser cannot cache it apart from the document that holds it. Email is a poor fit too, because some major clients, Gmail among them, do not show data URI images.

Formats
PNG, JPG, SVG, WebP, GIF, AVIF and ICO.
Output
Data URI, bare Base64, or CSS url(), with optional quotes.
Snippets
CSS, HTML, JSX and Markdown, each quoted the way it needs.
Size
Base64 is a third bigger than the file. Ceiling is 10 MB.

What the type comes from

The media type is read from the first bytes of the file, not from its name. A PNG renamed to .jpg still encodes as image/png, because that is what a browser will find when it decodes the data URI.

A PNG also says in the same header whether it has an alpha channel, so the tool can report that without decoding the picture. Other formats do not, and the tool says nothing instead of guessing.

Frequently asked questions

Should I inline all my images as Base64?
No. Inlining suits small assets in critical CSS. Bigger images are better as files, because Base64 adds a third to the size and cannot be cached on its own.
What size limit is sensible?
About 4 kB. Vite, for example, inlines files below 4 kB by default. Below that size, saving a request is worth the extra third. Above it, a separate file the browser can cache wins on repeat visits.
Does it keep transparency?
Yes. Encoding copies the exact bytes, so PNG and WebP alpha survives untouched. Nothing is decoded or re-encoded along the way.
Can I inline an SVG?
Yes, and it works like any other format. For text-based SVG, percent-encoding is usually shorter than Base64, so try the URL encoder as well.
Do animated GIFs still animate?
Yes. Every byte is preserved, so all the frames and the loop setting play exactly as they do in the file.
Is my image uploaded?
No. The file is read as bytes and encoded inside this page. It is never sent, logged or stored anywhere.
Browse all developer tools