Free Image Base64 Online

Convert images to Base64 data URIs, CSS, HTML img tags or raw Base64, in batches, and decode Base64 back to an image. Real file type detected. Runs in browser.

No login. Files processed for your request and discarded. Free to use. Files processed & discarded →

Compress PDF — it's free or choose from 130+ tools

130+ Free Tools
— Files Processed
— Happy Visitors
— Pages Explored
0 Files Stored

Image to Base64 Converter

Part of Image tools: See all Image tools.

What is Image Base64?

A free image to Base64 converter that also decodes Base64 back to an image. Drop one or many images, or paste a screenshot, and copy a data URI, raw Base64, a CSS rule, an HTML img tag, Markdown or JSON. SVGs can be URL-encoded instead. The real file type is read from the file's bytes, and everything runs in your browser.

How to use Image Base64

  1. Choose Image to Base64 and add images by picking, dragging or pasting with Ctrl+V.
  2. Pick the output: data URI, raw Base64, CSS, HTML img tag, Markdown or JSON.
  3. For SVGs choose Base64 or URL-encoded; for raw Base64 choose optional 76 or 64 character lines.
  4. Copy the result, copy all files, or download a .txt file.
  5. To go back, switch to Base64 to Image, paste Base64 or a data URI, and download the image.

Why use this tool?

Many converters only give raw Base64, label every file as PNG, or fail on a data URI with line breaks. This one writes the correct MIME type from the file's real bytes, shows the exact size increase per file, handles batches, URL-encodes SVGs, and decodes data URIs, URL-safe Base64 and missing padding with clear errors. Files are processed for your request and discarded.

FAQ

Does it give the full data URI or just the Base64?
Both. Choose Data URI for data:image/...;base64,... ready for HTML or CSS, or Raw Base64 for APIs and email parts. CSS, HTML img, Markdown and JSON outputs are also available.
How much bigger does Base64 make an image?
About 33 percent, because every 3 bytes become 4 characters, plus a short data: prefix. Each file's row shows its exact size before and after.
Which image formats work?
PNG, JPEG, GIF, WebP, AVIF, SVG, BMP, ICO and TIFF are detected from the file itself, as well as HEIC/HEIF and JPEG XL. Any of them can be encoded and decoded; formats your browser cannot display still download correctly, just without a preview.
Should I URL-encode SVGs instead of using Base64?
Usually yes. SVG is text, so a URL-encoded data URI is normally shorter than Base64 and compresses better. Pick Base64 only if the destination accepts nothing else.
Do Base64 images work in email?
Not everywhere. Some email apps show data URI images, but others, including Gmail on the web, remove them. A hosted image link or a CID attachment is more reliable; Raw Base64 with 76-character lines gives the body for a CID part.
Why will my Base64 not decode?
Common causes are a string cut off when copying, two strings pasted together, or stray characters. The decoder already ignores spaces and line breaks, adds missing padding and reads URL-safe Base64, and it tells you the exact character or problem otherwise.
Are my images uploaded?
No. Encoding and decoding happen in your browser; the images and Base64 text are not sent to our server.

What this image to Base64 converter does

This page turns an image file into Base64 text and turns Base64 text back into an image. Base64 is a way of writing any file, including a PNG, JPEG or SVG, using only 64 safe characters: the letters A to Z and a to z, the digits 0 to 9, plus and slash. Because the result is plain text, you can paste it straight into a stylesheet, an HTML page, a JSON payload, a Markdown file or an email template, and the image travels inside that text instead of as a separate file.

You can drop in one image or a whole batch. Each file gets its own row showing its real type, its size in pixels, its size on disk, how long the Base64 text will be, and how much bigger that is in percent. Click a row to show its result in the big box, or use the Copy button on the row. Copy all files and Download .txt collect every result at once.

Everything happens in your browser. The images you choose and the Base64 you paste are not uploaded to our server, which matters when the picture is a signature, an ID scan or a screenshot of something private.

How to convert an image to Base64

  1. Stay on Image → Base64 and choose one or more images, drag them onto the box, or copy a screenshot and press Ctrl+V (Cmd+V on a Mac) on the page.
  2. Pick the output you need: a full data URI, raw Base64, a CSS rule, an HTML img tag, a Markdown image or a JSON object.
  3. For SVG files, choose Base64 or URL-encoded. URL-encoded is usually shorter for SVG.
  4. Click Copy, or Download .txt for long results.

How to convert Base64 back to an image

  1. Switch to Base64 → Image.
  2. Paste the Base64. It can be bare Base64, a full data URI, or a whole CSS rule or img tag that contains one; the tool finds the data URI inside it.
  3. The preview appears as you paste. It shows the real file type, the pixel size and the file size.
  4. Click Download to save the file with the right extension, or Save as PNG to convert it.

The output formats explained

Data URI. This is the form browsers understand directly: data:image/png;base64, followed by the Base64 text. Put it anywhere a URL to an image would go, such as the src of an img tag or inside url() in CSS.

Raw Base64. Just the encoded characters, with no data: prefix. This is what most APIs want when a JSON field is documented as "base64-encoded image", and what you need for MIME email parts. You can add line breaks every 76 characters, the length email standards use, or every 64 characters, the length used in PEM files.

CSS background-image. A ready rule named after the file, for example .logo { background-image: url("data:...") }. For small icons up to 256 pixels the rule also sets the width and height and stops the background repeating, so the icon shows at its natural size straight away.

HTML img tag. An img element with the data URI as its src, alt text taken from the file name, and the real width and height. Setting width and height stops the page jumping as it loads. Change the alt text to describe the picture for screen-reader users.

Markdown image. The ![alt](data:...) form. Many Markdown viewers accept it, but some sites, including GitHub READMEs, strip or refuse data URIs, so check where the Markdown will be shown.

JSON object. The file name, type, size, width, height and raw Base64 in one object, handy for test fixtures and API mock data.

Why Base64 makes files about a third bigger

Base64 writes every 3 bytes of the file as 4 characters. That alone makes the text 4/3 of the original size, roughly 33 percent bigger, and the data: prefix adds a few more characters. Very small files can show a higher percentage, because the fixed prefix and the padding at the end count for more when the file is only a few hundred bytes. The tool shows the exact sizes for every file, so you do not have to guess.

If your web server compresses text with gzip or Brotli, part of that overhead is won back when the CSS or HTML is sent, but the decoded image still costs memory in the browser, and the text cannot be cached separately from the page or stylesheet it sits in.

When inlining an image is a good idea, and when it is not

Inlining helps with small images that every page needs anyway: a tiny logo, a few interface icons, a loading spinner, a background pattern. The image arrives with the CSS or HTML, so there is no extra request and no flash of a missing icon. It is also useful for single-file deliverables, such as an HTML report, a demo, a bookmarklet or a test fixture, where you do not want to ship a folder of images alongside.

It is a poor fit for photos and large graphics. A 200 KB photo becomes about 270 KB of text that has to be downloaded and parsed before the stylesheet or page that contains it can finish, and the browser cannot cache the photo on its own or load it lazily. Since browsers fetch many files at once over HTTP/2, the old reason for inlining, saving requests, matters much less than it used to. As a rough rule, keep inlined images to a few kilobytes each. The tool marks any file over 20 KB as large for inline use.

Base64 images in email

Email is where people most often reach for Base64, and the results are mixed. Some email apps show data URI images in the message body. Others, including Gmail on the web, remove them, so the reader sees a gap. The two methods that work most widely are a normal link to an image hosted on a web server, or a CID attachment, where the image is attached to the message as its own MIME part, Base64-encoded with line breaks every 76 characters, and the HTML refers to it by its content ID. The Raw Base64 option with 76-character lines produces that part's body. Test with the email apps your readers actually use.

SVG: Base64 or URL-encoded?

SVG files are already text, so Base64 is not the only choice. A URL-encoded SVG data URI keeps the markup readable and only escapes the characters that would break a URL, such as angle brackets, hashes and double quotes. For most icons it is noticeably shorter than Base64, and it compresses better with gzip. The tool also collapses line breaks and runs of spaces in the markup before encoding. Choose Base64 if the place you are pasting into expects only Base64 or treats percent signs specially.

How the file type is detected

The tool does not trust the file name. It reads the first bytes of the file, which identify the format, and uses that to write the MIME type in the data URI. A file saved as photo.jpg that is really a PNG is labelled PNG, with a note on its row, and gets data:image/png. It recognises PNG, JPEG, GIF, WebP, AVIF, HEIC and HEIF, BMP, ICO and CUR, TIFF, JPEG XL and SVG.

The same check runs when decoding. If a data URI says image/png but the bytes are a JPEG, the tool tells you, previews it correctly and saves it as .jpg. If the Base64 is not an image at all, for example a PDF or a ZIP, it says so and still lets you download the file. Formats your browser cannot draw, such as HEIC in most browsers, still decode and download; there is just no preview.

Pasted Base64 that will not decode

The decoder accepts the common variations without fuss. Spaces and line breaks are ignored, missing = padding at the end is added back, and URL-safe Base64, which uses - and _ instead of + and /, is read as normal. When something really is wrong, the message says what and where: an invalid character and its position, padding in the middle (usually two strings pasted together), or a length that cannot be complete. If the preview fails even though the text decodes, the data was most likely cut off when it was copied, which is common with very long strings in chat apps and spreadsheets.

Limits

Files over 25 MB are skipped, because the Base64 text would be too large to paste anywhere useful. Encoding does not resize, compress or strip metadata from the image; the Base64 holds the file exactly as it is, including any EXIF data such as camera details or location. If size matters, shrink the image first with an image compressor or resizer, then encode the smaller file.

Also try

Related tools that work well with this one: