sqwartHome

Convert Image to Base64

Get a Base64 string or data URI for any image, ready to paste into HTML, CSS, JSON or Markdown.

  • Free
  • No upload
  • No watermark
  • No sign-up
How it works

How to convert Image to Base64

  1. 1

    Choose or paste an image.

  2. 2

    Pick the output: data URI, raw Base64, CSS, HTML or Markdown.

  3. 3

    Copy it, or download it as a .txt file.

  4. 4

    Paste it into your code.

In detail

What Base64 is for

Base64 writes binary data, like an image, using only 64 safe text characters, so it can live inside text formats: a data URI in HTML or CSS, a field in JSON, an email template, or a single-file demo. The browser decodes it back into the image without a separate request.

The encoding is exact: decoding gives back the same bytes, so there's no quality change. The file type is detected from the image's contents, so the data URI's MIME type is right even if the file name is wrong.

When to use it, and when not to

  • Good: small icons, logos and SVGs under a few KB, email signatures, one-file HTML pages, and test fixtures.
  • Not good: photos and large images. Base64 is about 33% bigger than the file, can't be cached separately and delays page rendering. Serve those as normal files.
  • For SVG, a URL-encoded data URI can be smaller than Base64, but Base64 is the most compatible.

How it works, and why nothing is uploaded

Your browser already knows how to open JPG, PNG, WEBP, GIF, BMP and SVG files, and recent browsers open AVIF too. This tool asks the browser to decode your picture, draws it on an HTML canvas, and has the browser write the new file. iPhone HEIC photos and TIFF scans, which Chrome and Edge can't open, are decoded by small open-source decoders (libheif compiled to WebAssembly, and UTIF.js) that load only when you add such a file.

Because everything happens on your device there is no upload wait, no queue and no file-size cap other than your device's memory. A browser canvas tops out around 16,000 pixels on a side (less on older iPhones), which is far beyond any phone or camera photo.

FAQ

Questions, answered.

How much bigger is Base64?

About a third bigger than the original file: every 3 bytes become 4 characters.

What's a data URI?

A link that contains the file itself: data:image/png;base64, followed by the Base64 text. You can use it anywhere an image URL goes.

Can I convert Base64 back to an image?

Yes, with the Base64 to image tool.

Is there a size limit?

No set limit, but strings of several megabytes are slow to copy and paste. Browsers handle data URIs of many megabytes.

Are my images uploaded anywhere?

No. The page does all the work inside your browser, so your pictures never leave your phone or computer. Once the page has loaded you can even turn off Wi-Fi and it keeps working.

Is it really free? Is there a limit?

Yes, it is free with no sign-up and no watermark. There is no daily limit or file cap, because your own device does the work rather than a paid server.

Keep going

More free image tools