Convert an image to a data URL

Create a data URL or plain Base64 from an image in your browser. Choose the output format, then copy or download the complete text.

Loading tool…

Local processing · No account · Individual file downloads

How to convert Image to Base64

  1. Select “Select Files” and choose your Image files.
  2. Under “Text output format”, choose Data URL for HTML/CSS or Plain Base64 when the destination requests only encoded text.
  3. Select “Convert all to Base64”. Review the text, then use “Copy” or “Download”.

Choose the text output format

Under Text output format, select the mode required by your destination. The preview, Copy, and Download actions all use that selection.

ModeUseContents
Data URLHTML img / CSS background-imageMIME prefix + Base64 text
Plain Base64A field or API requesting encoded data onlyNo data: prefix

A valid HTML and CSS example

The example below embeds a red 1 × 1 pixel PNG. Replace its data URL with the complete output for your image.

HTML
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR4nGP4z8DwHwAFAAH/iZk9HQAAAABJRU5ErkJggg==" alt="Red pixel" width="1" height="1">
CSS
.sample {
  background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR4nGP4z8DwHwAFAAH/iZk9HQAAAABJRU5ErkJggg==");
}
Plain Base64
iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR4nGP4z8DwHwAFAAH/iZk9HQAAAABJRU5ErkJggg==
Download the example PNG

Encoded size and destination limits

The Base64 payload contains 4 × ceil(bytes / 3) characters, plus the prefix in Data URL mode. That typically adds about a third before any transport compression. Confirm that the destination accepts data URLs or Base64 and check its length limit.

Image files vs Base64 data URLs

AspectImageBase64
Primary strengthReusable file that can be cached and managed separately.Self-contained text string for code and payloads.
Best use caseUse normal files for production images and reusable assets.Use Base64 for small embedded assets, prototypes, and snippets.
Main trade-offImage files require a path, host, or asset pipeline.Base64 is portable but increases document or payload size.
Workflow fitKeep the Image file when it remains useful as the source or archive.Use Base64 when it better fits small icons, HTML snippets, CSS backgrounds, and JSON payloads.

Things to know before converting

  • Check the destination’s required format and length limit.
  • Copy the complete output, not a shortened preview.

Frequently Asked Questions

What is an image Base64 data URL?

It is a text string that embeds the image data directly, usually starting with data:image/...;base64, so it can be pasted into code.

Should I convert every image to Base64?

No. Base64 is best for small, self-contained assets. Normal image files are usually better for large or repeated production images.

Does the image to Base64 converter upload files?

No. The encoding happens locally in your browser.

Related tools

Adjust image file size