DevGrill

Image to Base64

Turn an image into a Base64 data URI for CSS, HTML or Markdown, or a data URI back into an image.

Runs in your browser

Image

When to put an image in Base64

A data URI puts an image's bytes straight into your code, like data:image/png;base64,iVBORw0…, so there's no separate file to load. It's handy for small icons in CSS, images in HTML emails, single-file demos and embedding images in JSON.

Drop, choose or paste an image and get it as a data URI, plain Base64, a CSS background-image, an HTML <img> tag with its width and height, or Markdown. Going the other way, paste a data URI or Base64 to see the image and download it. The type is read from the file's own bytes, so a mislabelled data URI is caught.

How to use the Image to Base64

  1. Add an image. Drop it on the box, click to choose a file, or paste a screenshot with Ctrl/Cmd V.

  2. Pick a format. Data URI, Base64 only, CSS, HTML or Markdown. The HTML tag includes the image's size.

  3. Copy it. The size line shows how big the result is compared with the file.

  4. Decoding instead? Switch to Base64 → Image, paste the text, and download the picture.

Tips

  • Base64 makes files about a third bigger, and inline images can't be cached on their own. Keep it for small images, roughly under 10 KB.
  • For SVG icons in CSS, a URL-encoded data URI (data:image/svg+xml,%3Csvg…) is often smaller than Base64. This tool decodes both.
  • Some email clients block data URI images; test before relying on them in newsletters.

Frequently asked questions

Which image types work?

PNG, JPEG, GIF, WebP, AVIF, SVG, ICO and BMP. The type comes from the file's first bytes, not its name.

Is there a size limit?

Only your device's memory, but data URIs over a few hundred KB make pages and stylesheets slow to parse. For big images, use a normal file.

Why does my decoded image say it's labelled differently?

The data URI says one type (for example image/png) but the bytes are another (for example JPEG). Browsers usually still show it, but it's worth fixing the label.

Is my image uploaded?

No. It's read and converted in your browser and never leaves your device.

Related tools