Image to base64 converter cropped

PNG, JPEG, WebP, GIF, SVG, BMP or ICO, up to 5 MB. The file is read in your browser and never uploaded anywhere.

Base64 is about a third larger than the image itself, so a 1 MB image becomes roughly a 1.4 MB string — pasting a large data URI into HTML or CSS makes the file much bigger and slower to load. Use data URIs for small images (icons, tiny graphics) and keep large images as ordinary files. The file is read in your browser and never leaves your device.

What is the Image to Base64 Converter?

An image to base64 converter is a tool that turns an image file into a Base64 data URI — a long text string that contains the whole image and can be pasted directly into HTML or CSS. Instead of linking to an image file, you embed the image itself, as text, inside your page or stylesheet.

A data URI looks like this (shortened — a real one is much longer):

data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8Xw8AAwMCAO+ip1sAAAAASUVORK5CYII=

The part before the comma says what the file is (image/png), and the part after it is the image itself, encoded as Base64. A browser that sees this in an <img src="…"> or a CSS background-image renders the picture exactly as if it had loaded a file.

This tool accepts PNG, JPEG, WebP, GIF, SVG, BMP, and ICO files up to 5 MB. It shows a preview of your image, along with its file name, MIME type, dimensions, file size, and the length of the generated string. The file is read locally in your browser with the FileReader API and is never uploaded anywhere — nothing leaves your device.

How to use the Image to Base64 Converter

  1. Click “Choose an image” and pick a file from your device. PNG, JPEG, WebP, GIF, SVG, BMP, and ICO are accepted, up to 5 MB.
  2. Check the preview on the right — your image appears, together with its details: file name, MIME type, dimensions, file size, and Base64 length.
  3. Read the Base64 data URI in the output box underneath the details.
  4. Copy or download it. Copy data URI puts the full string on your clipboard; Download saves it as a file. Clear removes the image and starts over.

Worked example

Upload a small PNG icon — say a 32 × 32 red dot — and the tool shows something like this:

  • File name: dot.png
  • MIME type: image/png
  • Dimensions: 32 × 32
  • File size: 97 bytes
  • Base64 length: 132 characters

The output box holds the complete data URI, ready to paste into your code:

<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAIAAAD8GO2jAAAAKElEQVR4nO3N..." alt="Red dot">

(The string is shown shortened here; the full data URI is 154 characters long.)

For a tiny 1 × 1 transparent PNG, the whole data URI is short enough to show in full:

data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8Xw8AAwMCAO+ip1sAAAAASUVORK5CYII=

Larger images produce much longer strings — a 100 KB photo becomes roughly a 137 KB string — which is why the tool shows the Base64 length, so you can judge whether the result is practical before you paste it in.

Where an image to Base64 converter is actually useful

Small icons and logos. A tiny logo, favicon, or button icon embedded as a data URI means the page needs no extra file for it. The page loads in one request instead of several, which is the classic use for this technique — and exactly the case where the size penalty does not matter.

Self-contained HTML files. An email template, a single-file demo, or a page you want to send to someone as one file cannot rely on separate image files. Data URIs let the images travel inside the document itself, so the file works anywhere, even offline.

CSS backgrounds and placeholders. A subtle texture, a loading placeholder, or a tiny pattern can live in your stylesheet as a data URI. It keeps the stylesheet self-contained and avoids a separate request for a file that is only a few hundred bytes anyway.

Tips for using data URIs well

  1. Use them for small images only. Base64 is about a third larger than the image itself, so a 1 MB image becomes roughly a 1.4 MB string. Pasting that into HTML or CSS makes the file much bigger and slower to load. Icons and tiny graphics are the sweet spot; keep large photos as ordinary files.
  2. Watch the file size, not just the image size. The tool shows both the file size and the Base64 length. If the Base64 length runs into hundreds of thousands of characters, your page will be heavy — consider compressing the image first or linking to it as a file instead.
  3. Pick the right format before converting. A photo should be JPEG or WebP, a logo or icon with flat colours should be PNG or SVG, and a simple animation needs GIF. Converting a 2 MB PNG photograph to a data URI is almost never the right answer; converting a 2 KB icon usually is.
  4. Remember that data URIs are not cached separately. A linked image file is downloaded once and cached by the browser; a data URI is re-downloaded every time the page or stylesheet loads. If the same image appears on many pages, a file is the better choice.
  5. Keep the 5 MB limit in mind. Files over 5 MB are refused, and other file types — documents, videos, audio — are refused too. The tool only accepts browser-compatible image formats, so a rejected file usually means it is too large or not an image.

Frequently asked questions

What is a data URI?

A data URI is a way of embedding a file directly in a web page or stylesheet as text. It starts with data:, then the MIME type (such as image/png), then ;base64,, then the file’s contents encoded as Base64. The browser decodes it and treats it exactly like a loaded file.

Why is the Base64 string longer than my image?

Base64 represents every 3 bytes as 4 characters, so the encoded string is about 33% larger than the original file. A 75 KB image becomes roughly a 100 KB string, and a 1 MB image becomes roughly 1.4 MB. That is a property of the encoding, not a problem with the tool.

Which image formats can I convert?

PNG, JPEG, WebP, GIF, SVG, BMP, and ICO — the formats browsers can display. Files must be 5 MB or smaller. Other types are refused, because a data URI only makes sense for content a browser can render.

Is my image uploaded anywhere?

No. The file is read locally in your browser using the FileReader API and is never sent to a server. You can convert a private photo, a client’s logo, or anything else without it leaving your device.

Should I use a data URI or a normal image file?

Use a data URI for small images — icons, tiny graphics, placeholders — where saving a separate request is worth the size penalty. Use a normal file for anything large, anything reused across many pages, or anything you want the browser to cache. When in doubt, check the Base64 length the tool shows you: if it is longer than a short paragraph, a file is probably better.

Conclusion

The Image to Base64 Converter turns any small image into a data URI you can paste straight into HTML or CSS, with a preview and the exact size cost shown before you commit. Try it with a small icon and see the result for yourself. And if you need to encode text rather than an image — a token, a snippet, or a piece of data — the Base64 Encoder and Decoder on this site does the same job for plain text, with Unicode handled correctly in both directions.

Related Tools