Skip to content
T
Tools.Town
Free Online Tools for Everyone
data:image

Image to Base64

100% Free

Convert any image to a base64 data URL — paste-ready for HTML, CSS, and JSON — or decode a data URL back to an image. Nothing is uploaded.

Instant
Client-Side
Encode + Decode

Encoding runs in your browser — your image is never uploaded.

Your base64 string and data URL will appear here.

Embed This Tool

Easy to Embed

Add Image to Base64 to your website or blog in seconds.

  • Responsive design
  • Lightweight & fast
  • No backend required
  • Always up-to-date
<iframe
  src="https://tools.town/embed/image-base64-converter/"
  width="100%"
  height="600"
  style="border:none; border-radius:12px;"
  loading="lazy"
  title="Image to Base64">
</iframe>

Share This Tool

Share Instantly

Share Image to Base64 with anyone — no login required.

  • Shareable link
  • No login required
  • Works on any device
  • No account needed

Share via

Advertisement

How to Use

  1. 1 Pick a direction: Image → Base64 to encode, or Base64 → Image to decode.
  2. 2 To encode, upload an image — the data URL and a ready-to-paste CSS snippet appear instantly.
  3. 3 Copy the data URL or the CSS background rule with one click.
  4. 4 To decode, paste a base64 string or full data URL to preview and download the image.
  5. 5 Everything runs in your browser — nothing is uploaded.

Features

  • Two directions: encode an image to base64, or decode base64 back to an image.
  • Outputs a full data URL plus a copy-ready CSS background-image rule.
  • Shows the decoded byte size and detected MIME type.
  • Decode works with or without the data: prefix — the format is auto-detected.
  • 100% client-side — your image and base64 never leave your device.

Why it Matters

Inlining a small image as a base64 data URL removes a separate network request, which can speed up the first paint of a page and is the only way to embed an image in a single self-contained HTML file, an email template, or a JSON payload. Doing the conversion in the browser matters because base64 strings are often pasted straight into source code — uploading the source image to a random web service to get that string is an unnecessary risk. This tool encodes and decodes locally, so the bytes stay with you.

★★★★★

Use Cases

Inline in CSS/HTML

Embed a small icon or background directly as a data URL to save an HTTP request.

Email & JSON

Drop an image into an email template or a JSON API payload where you can't link a file.

Quick Decode

Paste a data URL from someone's code to instantly see and download the image it represents.

Private Conversion

Generate base64 from sensitive artwork without uploading it anywhere.

How to use

  1. Pick a direction: Image → Base64 to encode, or Base64 → Image to decode.
  2. To encode, upload an image. The full data URL and a ready-to-paste CSS background rule appear instantly, along with the MIME type and decoded size.
  3. Copy the data URL or the CSS snippet with one click.
  4. To decode, paste a base64 string or a full data URL — the image previews and a Download button appears.

What a data URL looks like

A base64 data URL packs an image’s bytes into a single string:

data:image/png;base64,iVBORw0KGgoAAAANSUhEUg…

The browser reads the data: prefix, the MIME type (image/png), the ;base64 marker, and then the encoded bytes — and renders it exactly like a linked image.

When to inline an image

Inlining shines for small assets — icons, tiny backgrounds, a logo inside an email — because it removes a separate network request. It’s a poor fit for large images: base64 is about 33% larger than the raw file, it can’t be cached on its own, and it bloats your HTML or CSS. A good rule of thumb is to inline only images of a few kilobytes or less.

Private by design

Both encoding and decoding happen locally in your browser. Your image and the resulting base64 string are never uploaded, so the conversion is instant and your files stay private.

Frequently Asked Questions

What is a base64 data URL?
It's a way to embed a file's bytes directly inside text. A data URL looks like data:image/png;base64,iVBOR… — the data: prefix, the MIME type, the ;base64 marker, and then the image bytes encoded as base64 text. Browsers treat it exactly like a normal image URL, so you can drop it into an <img> src or a CSS background-image.
When should I inline an image as base64 instead of linking it?
Inlining works best for small images — icons, tiny backgrounds, a logo in an email. It removes a separate network request, which can help first paint. For larger images it's usually counterproductive: base64 is about 33% bigger than the raw file, it can't be cached separately, and it bloats your HTML or CSS. A rough rule of thumb is to inline only images under a few kilobytes.
Why is the base64 string bigger than my original file?
Base64 represents every 3 bytes of data as 4 text characters, so the encoded string is roughly 33% larger than the original binary. The tool shows the decoded byte size so you can compare against the file you started with.
Can I decode a base64 string back to an image?
Yes. Switch to the Base64 → Image tab and paste either a raw base64 string or a full data URL. The tool detects the format, previews the image, and gives you a download button. It works with or without the data: prefix.
Is my image uploaded anywhere?
No. Encoding and decoding both happen entirely in your browser. Your image and the resulting base64 never leave your device.

Related Tools You Might Like

Browse more free tools