ToolDash
Image to Base64

Image to Base64 Converter

Drop an image to get its base64 data URL, ready to paste into CSS, HTML or Markdown. The encoding happens in your browser, so the file is never uploaded.

  • Free, no sign-up
  • Runs in your browser — nothing is uploaded
  • Instant results, no waiting on a server

Encode any image as a base64 data URL for inline embedding in HTML, CSS, Markdown, or as a raw string. Nothing leaves your browser.

Source

Drop files here or click to browse

Base64 grows the payload by about 33% — best for small icons, not large photos.

Drop an image on the left to see the encoded output here.

How to convert an image to base64

  1. 1Drag an image onto the Source area or click to browse. A thumbnail appears with the original size and the encoded size.
  2. 2Choose an output tab: Data URL for the raw string, CSS for a background-image declaration, HTML for an img tag, or Markdown for an image link.
  3. 3Click Copy to put the snippet on your clipboard, or Save .txt to download it as a text file.

When inlining images as base64 makes sense

A data URL embeds a file directly in text. It looks like data:image/png;base64, followed by the file's bytes encoded as base64, an alphabet of 64 printable characters. Because each character carries 6 bits instead of 8, the encoded string is about 33% larger than the original file. This base64 image encoder works on the file's raw bytes, so the string decodes back to an identical file. The prefix also declares the MIME type, so the browser knows how to decode the data without a file extension. The tool shows both sizes so you can see the overhead.

Inlining is worth it for small assets. A tiny icon or background pattern embedded in CSS saves an HTTP request, never shows a loading flicker and travels with the stylesheet wherever it goes. It's also handy for self-contained HTML files, test fixtures and JSON payloads that need to carry an image.

For anything larger than a few kilobytes, it's usually a mistake. The browser can't cache the image separately, so it's downloaded again whenever the CSS or HTML changes. Large strings bloat the files that block rendering, and the browser has to parse them before it can paint. A 200 KB photo inlined into your stylesheet delays the whole page, while the same photo as a normal file would load in parallel and be cached for later visits.

If you inline SVG, consider that it's already text. Converting SVG to base64 works, but URL-encoding the SVG markup often produces a shorter data URL. For raster images, compress or resize first so you're inlining as few bytes as possible. And for email, many clients don't display data URL images at all, so hosted images are still the safer choice there.

When developers reach for it

Inlining small CSS icons

Embed a tiny arrow, spinner or texture as a background-image so it renders without an extra request.

Single-file HTML pages

Build reports, demos or offline pages that work as one .html file with all images included.

Convert image to base64 for API payloads

Paste the string into a JSON fixture or request body when an API expects images as text rather than file uploads.

Quick prototypes

Drop an image into a CodePen or sandbox without hosting it anywhere first.

Frequently asked questions

Why is the base64 string bigger than my image?

+

Base64 represents every 3 bytes of data with 4 text characters, so the output is roughly 33% larger than the original file, plus the short data URL prefix.

When should I avoid base64 images?

+

Avoid it for anything more than a few kilobytes. Inlined images can't be cached on their own and make your HTML or CSS heavier, which slows down rendering.

How do I add a base64 CSS background image?

+

Choose the CSS tab and copy the background-image declaration. Paste it into any rule, for example a .icon class, and add a width and height.

Image to data URL or plain base64: which do I need?

+

Anything that takes a URL, such as an img src, CSS url() or a Markdown image, needs the full data URL, which starts with data:image/png;base64, and names the MIME type. Some APIs want only the base64 part; copy from the Data URL tab and delete everything up to and including the comma.

Is my image uploaded?

+

No. The file is read with the browser's FileReader API and encoded locally, so it never leaves your device.

Which image formats are supported?

+

Any image file your browser recognizes, including PNG, JPEG, GIF, WebP and SVG. PNG to base64 is the most common case, for small icons that need transparency. The file's bytes are encoded as-is, so the format and quality stay exactly the same.