Image to Base64 Converter

Turn an image into Base64 text you can paste straight into HTML, CSS or JSON. Get the full data URI or just the Base64 string, copy it with one click, or download it as a text file — your image never leaves your device.

Runs in your browser — your files never leave this device

How do I convert an image to Base64?

Drop an image here: this free online image to Base64 converter turns it into Base64 text in your browser — a full data URI, or Base64 only, your choice. Copy the result to the clipboard or download it as a .txt file, with nothing uploaded.

Drop your image here
or click to browse · JPG, PNG, WebP, GIF, BMP, AVIF or SVG · animated GIFs export the first frame only

Related tools

How to use the Image to Base64 Converter

  1. Drop an image onto the box above, or click to browse.
  2. The Base64 text appears instantly in the box on the right.
  3. Choose “Full data URI” for HTML and CSS, or “Base64 only” for APIs and JSON.
  4. Press Copy to clipboard, or Download as .txt to save the text as a file.

For the full picture — what a data URI is, and when to embed instead of link — read our guide: How to Convert an Image to Base64.

What Base64 is, and why images become text

Base64 is a way of writing binary data — like an image file — using only 64 safe text characters: letters, digits, + and /. An image file is a sequence of bytes that text formats cannot hold, so Base64 re-encodes those bytes as plain text that can travel anywhere text can: inside an HTML file, a stylesheet, a JSON message or an email.

A data URI wraps that text with a small header saying what it is: data:image/png;base64, followed by the Base64 string. Browsers understand data URIs anywhere an image URL would go — in an img tag's src, in a CSS background, in a favicon link. The image is embedded in the page itself, so there is no separate file to load and no extra request.

When embedding makes sense — and when it does not

Embedding is ideal for small images: icons, logos, tiny illustrations, single-use graphics in an email or a standalone HTML file. It removes a network request, works offline, and keeps everything in one file. A 5 KB icon becomes about 7 KB of text — a fair trade for zero requests.

It is a poor choice for large images. Base64 adds about 33% to the size, so a 300 KB photo becomes 400 KB of text baked into your page — text that cannot be cached separately, cannot load lazily, and bloats every page view. As a rule of thumb, embed images under about 10 KB, and link larger ones as files. If your image is too big to embed sensibly, shrink it first with the Compress Image tool.

Data URI vs raw Base64

The full data URI — data:image/png;base64,iVBORw0KGgo… — is what HTML and CSS need: paste it into an img src or a url() and the browser renders the image. The header tells the browser the format, so the same string works for PNG, JPG, WebP and GIF.

Raw Base64 — just the encoded characters, without the header — is what APIs and data formats usually want. Many services accept an image as a Base64 string inside JSON, and some databases store images that way. This tool offers both: switch between them with the toggle above the output, and copy whichever your destination expects.

Data URI or Base64 only: embedding images in code

Convert image to Base64 data URI when the image needs to live inside the code: a data URI is the image, encoded as text, prefixed so a browser reads it as an image — paste it straight into HTML, CSS or JSON and the image travels with the file, with no separate image to host. The Base64 only option gives you the encoded text without the prefix, for APIs and tools that expect raw Base64.

The converter takes JPG, PNG, WebP, GIF, BMP, AVIF and SVG, one image at a time, and encodes only — it does not turn Base64 text back into an image. One thing to know before you embed: Base64 text is about 33% larger than the image it came from, so it suits small images — icons, tiny logos, single images in a document — better than large photos.

Frequently asked questions

Are my images uploaded to a server?

No. The conversion runs in your browser with the FileReader API. Your images never leave your device.

Why is the Base64 text larger than my image?

Base64 represents every 3 bytes of image data as 4 text characters, so the output is about 33% larger than the original file. That is inherent to the encoding, not a flaw in this tool.

What is the difference between a data URI and raw Base64?

A data URI is the full string starting with data:image/png;base64, — it tells the browser the format, so it works directly in HTML and CSS. Raw Base64 is only the encoded characters, which is what APIs and JSON usually expect.

Can I convert a large image?

Yes, but the output is very long — a 1 MB image becomes about 1.4 million characters. Browsers handle it, but pasting that much text is unwieldy. Compress the image first if you plan to embed it.

Does Base64 work for any image format?

Yes — JPG, PNG, WebP, GIF, BMP, AVIF and SVG all convert. The data URI header records the original format, so the browser decodes it correctly.

How do I use the result in HTML?

Paste the full data URI into the src attribute of an img tag. In CSS, use it inside url(): background-image: url(data:image/png;base64,…).

Can I convert a JPG to Base64?

Yes — JPG is one of the supported formats, along with PNG, WebP, GIF, BMP, AVIF and SVG. Drop the JPG here, choose data URI or Base64 only, and copy or download the result.

Can I convert the Base64 back to an image?

No — this tool encodes only. It turns an image into Base64 text; it does not turn Base64 text back into an image. For the reverse direction you need a decoder, which this tool does not include.

Can I convert several images at once?

No — one image at a time. Convert the first image, copy or download the result, then drop the next one. Each conversion runs in your browser, with nothing uploaded.