PUBLIC.INTERNET

Image to Base64 Data URI Converter

A data URI puts a whole image inside your HTML or CSS as text, for example data:image/png;base64,iVBORw0KG..., so the page makes no separate request for it. Choose an image and this converter Base64-encodes the file's exact bytes, so a GIF keeps its animation and an SVG stays a vector. If you set a max width, a max height or a quality, the image is redrawn on a canvas at the smaller size first. Files up to 10 MB are read in your browser and are not uploaded.

Upload image

Drag and drop an image or

PNG, JPG, WebP, GIF or SVG, up to 10 MB

How to Convert Images to Data URIs

  1. Drag an image onto the upload area, or press browse and pick a PNG, JPG, WebP, GIF or SVG file up to 10 MB.
  2. Check the Preview, which lists the file's original size, dimensions and type.
  3. To shrink the image, enter a Max width (px) or a Max height (px). The aspect ratio is kept and the image is never enlarged.
  4. For a JPEG or WebP, set Quality from 0.1 to 1.0 to recompress it. Leave all three fields empty to encode the original file.
  5. Press Generate Data URI, then Copy Data URI for the full string or Download Image for the image it encodes.

Original bytes or a redrawn copy

A data URI has the form data:[media type];base64,[data] (RFC 2397). Base64 writes every 3 bytes as 4 characters, so the string is about 33% larger than the file, and it cannot be cached apart from the document that contains it. That trade works for small icons and logos, where saving a request matters more than the extra bytes, and stops working for large photos. The Output line shows the decoded size and type of what you are about to paste, so you can compare it with the original.

With the three option fields empty, the output is the original file, byte for byte, with its own media type. A smaller max size or a quality redraws the image on a canvas, and that changes more than the size: an animation is reduced to a single frame, an SVG becomes pixels, and metadata is dropped. A canvas saves PNG, JPEG and, in browsers that can write it, WebP, so a redrawn GIF or SVG comes out as PNG. Quality only affects JPEG and WebP, which is why the field is disabled for other types. The status line states the size and type that were produced.