MrHimanshu.comAlways ready to work
Let’s talk

CODE / ENCODE

Image to Base64 Converter

Choose an image and get Base64 text, a data URI, a CSS snippet or an HTML img tag you can paste straight into your code. The image never leaves your browser.

Free · runs in your browser

Runs entirely in your browser. Nothing you enter is sent anywhere.

How to use Image to Base64

  1. Press Choose an image and pick a PNG, JPG, WebP, GIF or SVG file from your device.
  2. Pick the output you need: Data URI (works anywhere a URL does), Base64 only, a CSS background-image line, or an HTML img tag.
  3. Press Copy and paste the text into your stylesheet, HTML, JSON file or email template.
  4. Check the size line: Base64 text is larger than the image, so it suits small icons rather than photos.

What a Base64 image is

Base64 is a way of writing binary data, such as the bytes of an image, using only ordinary letters, digits, + and /. That lets an image travel inside text, for example in a CSS file, an HTML page, a JSON message or an email.

A data URI wraps the Base64 text with the file type, like data:image/png;base64,…, so browsers can show the image without fetching a separate file.

When to use it, and when not to

Base64 is useful for very small images, such as icons or a tiny logo, because it saves a request. It also helps where you can only paste text, for example in an HTML email template or a config file.

It makes the data about one third larger and the browser cannot cache it separately from the page, so do not use it for photos or large pictures. For those, compress the image with the Image Compressor and link to the file normally.

Frequently asked questions

Is my image uploaded?

No. The file is read and converted by your browser; nothing is sent to a server.

What is the difference between Base64 and a data URI?

Base64 is just the encoded text. A data URI adds the prefix data:image/png;base64, so a browser knows how to display it. Use the data URI in img tags and CSS, and plain Base64 when an API asks for it.

Why is the Base64 text bigger than my image?

Base64 uses four characters for every three bytes, so the text is about 33% larger than the original file.

Which image types work?

Any image your browser can open, including PNG, JPG, WebP, GIF and SVG.

How do I turn Base64 back into an image?

Use the Base64 to Image tool: paste the text and download the picture.

All 9 in Developer toolsBrowse all 38 free tools