Image to Base64 Converter

Drop, paste or pick an image and copy a data URI ready for HTML, CSS or Markdown. The other way round, paste Base64 or a data URI to see the image, check its real type and download the file.

The image is read and converted in your browser. It isn't sent to any server and isn't saved on the page.

Direction
Format

Result

No image yet

Choose an image or paste a screenshot with Ctrl+V. The code shows up here in the chosen format.

Got Base64 that isn't an image, a Basic header or a Kubernetes Secret? The Base64 decoder reads text and any file.

Decode Base64

What is a data URI

A data URI puts the file inside the address itself: data:image/png;base64, followed by the image bytes in Base64. The browser treats that text as an image URL, so it works in an img src, in CSS url(), in Markdown and in JSON. The part before the comma states the file type; if it's wrong, some browsers and upload validators reject the image.

When to inline an image and when not to

Worth inlining

  • Icons and logos of a few KB, which would each cost a request

  • Small background images in critical CSS loaded with the page

  • Test fixtures and API mocks, where the image has to travel inside the JSON

Better as a file

  • Photos and banners: Base64 is a third bigger and isn't cached by the browser separately from the page

  • The main image of the page, because a bigger HTML delays everything after it

  • Email marketing images, which Gmail and Outlook on Windows don't display as data URIs

SVG doesn't need Base64

SVG is text, so it can go into a data URI with percent-encoding, escaping only <, >, # and %. The result is usually smaller than Base64 and stays readable. Double quotes become single quotes so the value fits inside url("...") in CSS. Choose URL-encoded in the options when the image is an SVG.

Testing uploads and APIs with Base64 images

Many APIs take the image as Base64 inside JSON, with or without the data: prefix. For QA, two things matter. Size limits usually apply to the decoded file, and Base64 is about 33% bigger, so a 5 MB photo becomes roughly 6.7 MB of payload. Then there's the type: if the data URI says image/png and the bytes are JPEG, a backend that checks the file signature will reject it. Base64 to image mode shows both types side by side.

Formats the browser displays

PNG, JPEG, GIF, WebP, AVIF, SVG, ICO and BMP show up in any current browser. HEIC, the iPhone photo format, only opens in Safari; here it's converted and downloaded normally, but the preview may not appear.

Image to Base64 frequently asked questionsFrequently asked questions

Data URIs, email, SVG, uploads and images that won't open.