1. Home
  2. Images
  3. Image to Base64

Image to Base64

Encode an image as a Base64 data URI and copy it as CSS or HTML.

Runs in your browser · No upload Works offline

This is a sample SVG. Upload an image to replace it.

File
sample.svg
Type
image/svg+xml
Original size
255 B
Output length
366 chars
Increase
+43.5%
Dimensions
—
SVG encoding
Result
data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAzMiAzMiI+CiAgPHJlY3Qgd2lkdGg9IjMyIiBoZWlnaHQ9IjMyIiByeD0iNyIgZmlsbD0iI2ZmNWIxZiIvPgogIDxwYXRoIGQ9Ik05IDE2LjVsNC41IDQuNUwyMyAxMS41IiBmaWxsPSJub25lIiBzdHJva2U9IiMxNTE2MWEiIHN0cm9rZS13aWR0aD0iMy4yIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz4KPC9zdmc+

To turn Base64 back into an image, use Base64 to Image.

How to use

  1. Drop an image or click to choose one. Screenshots can be pasted directly with Ctrl+V (or Cmd+V).
  2. Choose an output: a data URI, the raw Base64 string, a CSS background rule, an <img> tag or Markdown.
  3. Use Copy or save the result as a .txt file.

A sample SVG icon is loaded when the page opens so you can see what the output looks like. Images are encoded in your browser and never uploaded.

How Base64 and data URIs work

Base64 represents binary data with 64 characters — A–Z, a–z, 0–9, + and / (RFC 4648). It turns every 3 bytes into 4 characters, so the result is about 33% longer than the file. Prefix it with data:<type>;base64, and you get a data URI (RFC 2397) that HTML and CSS can use in place of a file URL.

Output Looks like Where it goes
Data URI data:image/png;base64,iVBOR… Any URL slot: src, url()
Base64 only iVBOR… API request bodies, JSON fields
CSS background background-image: url("data:…"); Stylesheets
<img> tag <img src="data:…" width height alt> HTML pages, email signatures
Markdown ![alt](data:…) READMEs, docs

Examples

  • A 30,000-byte (about 29 KB) PNG becomes 40,000 characters of Base64, a 33.3% increase.
  • A 1,200-byte SVG icon is 1,600 characters in Base64, but URL-encoded it is usually shorter. SVG is already text (XML), so only a handful of symbols need escaping, such as < → %3C.

Things to keep in mind

  • Use it for small images. Icons, tiny logos and spinners of a few KB are a good fit. Because a data URI lives inside your HTML or CSS, the browser cannot cache the image separately, and it is downloaded again whenever that file changes.
  • It does not make files smaller. Base64 is an encoding, not compression. Compress the image first if size matters.
  • Some email clients do not display data URI images in signatures.

FAQ

Can I turn Base64 back into an image file?

Yes. Paste it into Base64 to Image to detect the format, preview it and save the file. For plain text rather than images, use the Base64 encoder/decoder.

For SVG, should I use Base64 or URL encoding?

URL encoding is usually shorter and stays readable. Choose Base64 if you need compatibility with very old tools or picky email environments.

Why does the data URI start with a type such as image/png?

The browser needs to know how to interpret the data. This tool uses the type reported for the file, falling back to the file extension.

Coming soon

Can't find the tool you need?

Tell us what you want to do. We build the most requested tools first.