Image to Base64: Encode Pictures as Data URIs

Turn any picture into a Base64 string or data URI you can drop into HTML, CSS, JSON or Markdown, and decode Base64 back into an image when you need to.

  • Data URI, HTML and CSS
  • Decode back to an image
  • Private: no upload
Drop an image here, click to choose, or paste with Ctrl+V PNG, JPG, WebP, GIF, SVG, ICO · nothing is uploaded
Decode Base64 back to an image

How to use the Image to Base64 tool

  1. Load a pictureDrop an image into the box, click to browse, or paste a screenshot with Ctrl+V.
  2. Pick the outputChoose a data URI, the bare Base64 text, an HTML <img> tag, a CSS background, Markdown or JSON.
  3. Copy itPress “Copy” and paste directly into your code, or save it as a text file.
  4. Decode if requiredExpand “Decode Base64 back to an image”, paste a string, then preview or save the picture.

Encoder features

  • Code snippets includedReceive the exact markup for HTML, CSS, Markdown or JSON rather than only the raw text.
  • Size comparisonSee how much the encoded version grows, with a warning when a picture is too big to inline sensibly.
  • Every common formatHandles PNG, JPG, WebP, GIF, SVG and ICO files.
  • Both directionsTurn Base64 strings and data URIs back into a viewable, downloadable image.
  • Stays on your deviceEncoding happens in your browser and pictures are never uploaded.

Base64 images in a nutshell

Base64 represents binary data, like an image file, using just 64 text-safe characters: capital and small letters, the digits 0–9, plus “+” and “/”. Encoded this way, a picture can sit right inside HTML, CSS, JSON or an email as ordinary text. Prefix it with its media type, such as data:image/png;base64,, and you have a data URI that browsers render just like a normal image address.

Good places for Base64 images

  • Very small icons and logos inside CSS or HTML, saving an extra network request.
  • Email templates and one-file HTML documents that can’t rely on external assets.
  • APIs and JSON payloads that take images as text fields.
  • Loading placeholders, like a tiny blurred preview displayed until the full picture arrives.

When to avoid it

Encoding inflates data by roughly a third (33%), because every three bytes turn into four characters. Inline pictures also can’t be cached on their own, and they bloat the HTML or CSS that has to be downloaded and parsed. A sensible rule is to inline only images under about 5–10 KB. Larger photos load faster as normal files, ideally slimmed down with our Image Compressor or converted to WebP.

The output options

  • Data URI: the complete string starting with data:image/…;base64,, usable anywhere a URL is accepted.
  • HTML: an image tag whose src attribute holds the data URI.
  • CSS: a background-image: url("…") declaration ready for a stylesheet.
  • Markdown: the familiar ![alt](…) image syntax with the data URI inside.

A tip for SVG: in CSS, a URL-encoded data URI is frequently shorter than Base64, and every modern browser understands both. To encode text or other file types, use our general Base64 Encoder & Decoder.

Frequently asked questions

How can I turn an image into Base64?
Drop it onto the tool or paste it with Ctrl+V. The data URI shows up instantly and copies with a single click.
Why is the encoded text bigger than the image?
Every three bytes become four characters, so the Base64 version ends up about 33% larger than the original.
Can Base64 be turned back into a picture?
Yes. Open “Decode Base64 back to an image”, paste a data URI or plain Base64, then preview or download the result.
Is there a maximum size?
You can encode images of up to 10 MB, though Base64 makes most sense for small files below about 10 KB.
Does my image get uploaded?
No. Encoding happens in your browser and the file stays on your device.