Image to Base64 Converter: Data URI, HTML & CSS

Image to Base64 Converter: Data URI, HTML & CSS

Drop a PNG, JPG, WebP, GIF or SVG up to 20 MB and copy raw Base64, a data URL, an <img> tag or a CSS url(). Runs in your browser, nothing uploaded.

Updated November 2026

Reviewed by Rafael Duarte

Speed
—
Privacy
Local Only
Payload
0 KB

Low Latency Encoding

Asynchronous processing handles large files without blocking the UI.

Local Processing

Assets are encoded in-browser. Data never leaves your machine.

Data URI Support

Directly generate CSS, HTML, and Data URL ready string formats.

How to convert an image to Base64

Four output formats, one click to copy

1. Drop the image

Drag a PNG, JPG, GIF, SVG or WebP file up to 20 MB onto the box, or click browse. Other image types such as AVIF, BMP or ICO also work if your browser recognizes them. One file at a time.

2. Pick the output format

Raw Base64, Data URL, HTML <img>, or CSS url().

3. Copy the result

Click Copy, or press Shift+Enter while the focus is outside the output box and other text fields.

What this Base64 image encoder does

More than just spitting out a string

Four output formats

Raw Base64, a full data URL, a ready-to-paste <img> tag, or a CSS url() value.

Shows image metadata

METADATA ANALYSIS lists the type, dimensions, File Size and Encoded Size, so you can see the roughly 33% Base64 overhead before you paste anything.

Zoomable preview

Open View image and zoom from 25% to 400% to check the picture before embedding it in your code.

Runs entirely in your browser

The FileReader API reads the file locally, so nothing is uploaded. Once the page has loaded, the conversion itself needs no network.

Examples

Output format
Result
Raw Base64
iVBORw0KGgoAAAANSUhEUgAA...
Data URL
data:image/png;base64,iVBORw0K...
HTML <img>
<img src="data:image/png;base64,..." alt="" />
CSS url()
url('data:image/png;base64,...')

When you'll reach for this tool

The most common scenarios among people converting images to Base64

Cut HTTP requests

Small icons and logos (under 5–10 KB) load inline with the HTML/CSS, skipping an extra network round trip.

Self-contained HTML

Single-file demos, prototypes, or offline docs work with zero external dependencies.

Previewing email templates

Handy for testing a layout locally, but support for data URL images varies between email clients. For real sends, hosted images or inline CID attachments are the safer choice.

API payloads

Webhooks and REST APIs that transfer images usually expect a Base64 string in the request body.

Canvas and WebGL

Base64 strings sidestep the CORS restrictions that apply to externally hosted images.

Going the other way

To paste Base64 and get the image back, use Base64 to Image. For text and other files, the Base64 Encoder is the right tool, and How to convert Base64 to text, image and file walks through every direction.

Common questions

Image too large to embed

Above a few KB, hosting the file separately usually beats inlining it as Base64.

Quality doesn't change

Base64 is lossless: the string represents exactly the same pixels as the original file.

Why encode here

Every conversion happens in the browser with the FileReader API, so your image is never uploaded. After the page has loaded, encoding needs no network connection.

The four output formats save you from hand-building the <img> tag or the CSS url() value: pick the one you need, copy it and paste it straight into your code. If you only need to encode text or a non-image file, use the Base64 Encoder instead.

Frequently asked questions

Use the data URL output and paste it as the src of an <img> tag, or pick the HTML <img> output format directly, since the tool already generates the full tag for you.

References

Related Tools