Drop an image and get a Base64 data URL you can paste into CSS, HTML, or JSON.
How image Base64 encoding works
Base64 lets binary data — like an image file — be represented as plain
text. That's useful when you need to embed an image inside something
that only accepts text, like a CSS file, an HTML attribute, or a JSON
payload. The tool produces a "data URL": a single string that starts
with a MIME type and then contains the entire image as Base64.
The data URL format
data:[mime-type];base64,[base64-encoded-bytes]
For a PNG image, the result starts with
data:image/png;base64, followed by the encoded bytes. You
can paste this whole string anywhere a URL is expected — into the
src attribute of an image tag, into a CSS
url(), or into a JSON string value.
How the encoding happens
The browser reads the file as bytes (using the FileReader API), then
encodes those bytes as Base64. The result is the same Base64 encoding
used by the Encoder tool — the only difference is that the input is
an image file instead of plain text. The tool then prepends the data
URL prefix based on the file's MIME type.
When to use data URLs — and when not to
Data URLs have real trade-offs:
-
Good for: small icons, logos, loading spinners,
favicons, and any tiny image you want to inline. Avoiding a separate
HTTP request genuinely speeds things up for these.
-
Bad for: photos, hero images, or any file larger
than ~50 KB. Base64 inflates the size by about 33%, and the browser
can't cache the image separately.
-
Also bad for: images that might be reused on
multiple pages. Inline data URLs get re-downloaded with every page.
How large is a Base64 image?
About 33% larger than the original file. A 10 KB PNG becomes roughly
13 KB of Base64 text. A 100 KB JPEG becomes about 133 KB. This is
because Base64 uses 4 characters to represent every 3 bytes of binary
data, and each character is stored as one byte in the HTML document.
Common questions
-
Does the image lose quality when encoded?
No. Base64 is lossless — the decoded image is byte-for-byte
identical to the original. Quality loss only happens if you re-encode
the image to a different format, which this tool doesn't do.
-
Can I use an SVG?
Yes. SVGs can be encoded as data URLs, though they're already text
(so you can also inline the SVG markup directly without encoding).
For SVGs, embedding the markup directly is usually smaller.
-
What's the practical size limit?
Most browsers handle data URLs of a few megabytes, but they're slow
to parse and difficult to work with. In practice, use the tool for
images under 50 KB and host larger images as regular files.