Image to Base64

Convert an image into a Base64 data URI in your browser, ready to paste into HTML, CSS or JSON.

Drop in an image and get the encoded string. The file is read on your device — nothing is uploaded, which matters if the image is not public.

How Does It Work?

  1. Choose an imageAny raster or vector image your browser can read. The file is opened locally with the FileReader API, so it never leaves your device.
  2. Pick the output you needA plain data URI, the Base64 payload on its own, or a ready-made HTML tag or CSS declaration you can paste directly.
  3. Copy itOne button puts the whole string on your clipboard, however long it is.

What Is It Used For?

Base64 turns binary data into plain text using 64 safe characters, which lets an image travel anywhere text can go — inside a stylesheet, an HTML attribute, a JSON payload or an email template. The trade-off is size: every three bytes become four characters, so an encoded image is about 33% larger than the original file, plus a little padding. That makes it worthwhile for small icons and logos, where you save a network request, and a poor idea for photographs, where you add weight to a file that then cannot be cached separately.

  • Embedding a small logo or icon directly in CSS to avoid an extra request.
  • Putting an image inside an HTML email template that must be self-contained.
  • Storing a small picture in a JSON document or a database text column.
  • Pasting an image into a code sandbox or a documentation page with no file hosting.
  • Passing an image to an API that expects a Base64 string rather than a file upload.

Examples

Original fileEncoded sizeSensible use?
2 KB SVG icon~2.7 KBYes — saves a request
8 KB PNG logo~10.7 KBYes for a single small logo
150 KB JPEG~200 KBRarely — it cannot be cached separately
2 MB photo~2.7 MBNo — link to the file instead

Frequently Asked Questions

Why is the Base64 version bigger than my file?

Base64 encodes every three bytes as four text characters, which is a fixed 33% increase, plus up to two padding characters. That overhead is the price of representing binary data as plain text.

When should I use a data URI instead of a normal image file?

For small, rarely-changing assets such as icons and logos, where removing an HTTP request is worth the extra bytes. For anything above roughly 10 KB, a normal file is better because browsers can cache it independently of the page.

Is my image uploaded anywhere?

No. The file is read by your browser using the FileReader API and encoded on your device. Nothing is transmitted, which matters when the image is a screenshot of something private.

Does this work with SVG files?

Yes. SVG encodes fine as Base64, though for SVG specifically a URL-encoded data URI is usually smaller than a Base64 one, because SVG is already text.

Can I decode Base64 back into an image?

Paste a complete data URI into a browser address bar and the image will display, which you can then save. This tool only handles the encoding direction.

Free. No registration. This tool runs entirely in your browser, so the data you enter stays on your device.