Convert images to Base64 Data URLs

Encode images as Data URL text for embedding in HTML, CSS or JSON. Every file is processed in the current browser and is never uploaded to HarnessTrail.

What this tool does

Convert images to Base64 Data URLs is useful for Embedded icons, Offline HTML, API testing. Decide the required dimensions, format and file-size target before processing to avoid unnecessary repeated encoding.

Accepted input: JPG, JPEG, JFIF, PNG, WebP, AVIF, GIF, SVG, BMP, ICO, HEIC, HEIF, PSD, TIFF and TGA (decoding support depends on the browser). Output: TXT text containing a Data URL. Actual format support also depends on the codecs available in the current browser.

After files are added, the browser decodes them in local memory and creates previews. Processing and export use the selected settings without sending source media to HarnessTrail servers.

What it is useful for

  • Embedded icons
  • Offline HTML
  • API testing

Supported formats

Input
JPG, JPEG, JFIF, PNG, WebP, AVIF, GIF, SVG, BMP, ICO, HEIC, HEIF, PSD, TIFF and TGA (decoding support depends on the browser)
Output
TXT text containing a Data URL

How processing works

How to use it

  1. 01Add the files you want to process with Convert images to Base64 Data URLs. You can select multiple files or a folder.
  2. 02Review names, formats, pixel dimensions and sizes in the queue, removing accidental or duplicate selections.
  3. 03Adjust the settings and test one representative file in the preview before running a large batch.
  4. 04Start processing and keep the tab open while the task queue is active.
  5. 05Verify dimensions, quality, transparency and size, then download files, create a ZIP or continue in another tool.

Settings explained

Recommended workflow

Quality checklist

Ideas for a complete workflow

Troubleshooting

Files cannot be added

Confirm that the extension matches the real format and try opening the file directly in the browser. Convert unusual encodings to a common format first.

Preview is blank or colors look wrong

Use a current browser and disable extensions that alter pages. HDR or unusual ICC data may look different in an sRGB preview.

Processing is slow

Use a smaller batch, close memory-heavy tabs and resize extremely large sources first. Decoded media can occupy many times its compressed size.

The size target is missed

Adjust dimensions, format and quality together. Complex content may not meet a strict limit through quality reduction alone.

The destination rejects the file

Verify its extension, MIME type, dimensions, size and color requirements, then test one real upload.

Privacy and local data

Compatibility and limits

Frequently asked questions

Are files uploaded?

No. Reading, processing and exporting all happen locally in your browser.

Does Convert images to Base64 Data URLs support batches?

Independent tools process files one by one. Combination tools such as stitching, comparison, GIF and PDF process the selected group together.

Why can results differ between browsers?

Browsers use different image and video codecs, color management and memory limits. Use a current version of Chrome, Edge, Firefox or Safari.

Why can an exported file be larger?

File size depends on pixel dimensions, content complexity, output format and quality. TXT text containing a Data URL is not always smaller than the source.

Can files be restored after closing the page?

Source files are not uploaded or permanently stored. Some settings can remain in browser storage, but important outputs should be downloaded promptly.

Can I use a phone or tablet?

Most tools work, but mobile memory is limited. Large batches, long videos, PDFs and GIF work are better handled in smaller groups or on desktop.

How do I make batch results more consistent?

Test one ordinary and one unusual file, then run the verified settings across the batch while keeping the tab open.

Why can the preview and download look slightly different?

Page scaling, display color, browser rendering and destination color management can differ. Judge the downloaded file in its final environment.

SEARCH-VERIFIED GUIDE

Use Base64 images without sending the source file to a server

Base64 represents binary bytes as text. A Data URL adds the MIME type and encoding prefix so the result can be pasted directly into HTML or CSS. Encoding increases text length, so it is best for small assets rather than large photographs.

Image to Base64 Data URL converter for HTML, CSS and JSON
Convert JPG, PNG, WebP and SVG images to Base64 Data URLs locally, with copy-ready examples for HTML, CSS, JSON and JavaScript.

Reproducible size example

Base64 uses four text characters for each three binary bytes, before the Data URL prefix.

1,024 binary bytes1,368 Base64 characters
10,000 binary bytes13,336 Base64 characters
PNG Data URL prefixdata:image/png;base64, (22 characters)
Reproducible method; real-file results vary with content and browser.

Base64 or Data URL?

Base64Encoded payload only; useful inside JSON or an API field
Data URLIncludes data:image/...;base64, and can be used as src or url()

Code examples

<img src="data:image/png;base64,..." alt="Example">
.icon { background-image: url("data:image/svg+xml;base64,..."); }

When to avoid it

Related workflows

Check the source with EXIF inspection, reduce it with image compression, or generate a lightweight placeholder before encoding.

Frequently asked questions

Does Base64 reduce image size?

No. Encoding normally increases the byte length; it changes representation rather than compressing the image.

What is the difference between Base64 and a Data URL?

A Data URL combines a MIME type, Base64 marker and encoded payload in one browser-ready string.

Are images uploaded?

No. Conversion runs in the current browser.

COPY-READY REFERENCE

Use the correct Base64 Data URL for each destination

HTML<img src="data:image/png;base64,…" alt="">
CSSbackground-image: url("data:image/webp;base64,…")
JSONStore the Data URL as a quoted string and escape it with JSON.stringify
JavaScriptAssign the complete Data URL to an image src property

Base64 size formula

The encoded character count is approximately 4 × ceil(binary bytes ÷ 3), plus the MIME prefix. A 100 KB file therefore becomes roughly 133 KB of Base64 text before surrounding HTML, CSS or JSON. Use image compression first when the asset is too large.

Caching, privacy and security

Embedded data cannot be cached as a separate image, makes source files harder to review and may be restricted by a Content Security Policy. Avoid putting private images in logs, analytics events or public source maps. Use Base64 for small, stable assets and keep larger images as normal files.

Need a lightweight visual fallback instead? Create a local image placeholder, or inspect dimensions before encoding with image information.

MEASURED BASE64 REFERENCE

Choose Base64 only when the delivery cost makes sense

Base64 changes binary bytes into printable characters; it does not compress an image. The payload length is 4 × ceil(bytes ÷ 3). A 30,000-byte icon becomes 40,000 Base64 characters before the Data URL prefix, markup and compression applied by the web server.

1 KB sourceabout 1.33 KB of Base64; reasonable for a small stable icon
30 KB sourceabout 40 KB before the MIME prefix; test transfer compression and caching
300 KB sourceabout 400 KB of text; a normal image URL is usually more maintainable

Copy-ready destinations

<img src="data:image/png;base64,..." width="32" height="32" alt="">
.icon { background-image: url("data:image/webp;base64,..."); }
const payload = { image: "data:image/jpeg;base64,..." };

Decision checklist

For performance work, first use image compression, then encode the final asset and compare the document transfer size in browser developer tools.

BASE64 DECISION GUIDE

Convert an image, copy the right output and know its cost

Raw Base64 contains only encoded characters. A Data URL also contains the media type and ;base64, marker. Use the complete Data URL in an HTML image or CSS URL; use raw Base64 only when an API field explicitly asks for it.

HTML
<img src="data:image/png;base64,..." alt="Description">
CSS
.icon { background-image: url("data:image/webp;base64,..."); }
JavaScript
image.src = dataUrl;
JSON
{"image":"data:image/png;base64,..."}

Size and performance calculation

Base64 length is approximately 4 × ceil(bytes ÷ 3). A 100,000-byte image becomes about 133,336 Base64 characters before the prefix. Small icons may be convenient to embed, while content photographs are usually better as separate cacheable files.

Common failures

Convert an image to Base64 →Compress before encodingCreate a placeholder
BASE64 TOOLKIT

Complete the Base64 workflow

Prepare the source with image compression, verify dimensions and metadata, then convert it to a browser-ready Data URL. For small previews, compare the result with an image placeholder.