Toolvore

Image to Base64

Convert an image file into a Base64 data URI.

This tool runs entirely in your browser. Your data is never uploaded, never stored, and never leaves your device.

Converts an image file into a complete Base64 data URI, mime prefix included, ready to paste straight into an img src, a CSS background-image or a JSON field with no separate file to host.

How to use it

  1. 1Drop in the image — PNG, JPEG, GIF, WebP and SVG all work.
  2. 2Check the preview and the file size shown next to the filename.
  3. 3Copy the whole data URI out of the box with the Copy button.

Example

Input
logo.png, 12 KB
Output
data:image/png;base64,iVBORw0KGgoAAAANSUhEU… — roughly 16 KB of text

Base64 costs about a third more than the bytes it encodes, so inlining is worth it for icons and small logos and stops being worth it quickly after that. Every PNG begins iVBORw0KGgo because that is its file signature encoded.

What happens to your data

The file is read locally with the browser's FileReader and the data URI is built on your machine. Nothing is uploaded — which matters, since the images people encode are often signatures, ID photos and unpublished artwork.

Last updated August 2026

Something in the job wants the image itself rather than a link to it — a stylesheet that ships on its own, a JSON field called avatar, an HTML report that opens from a memory stick with no assets folder, an email signature you would rather not host anywhere. Encoding it as text is how bytes travel where only characters are allowed.

Decide first whether inlining is right at all, because it is a trade rather than an upgrade. A hosted image is fetched once, cached, and replaced by uploading over it. An inlined one costs no request and can never 404 — and it rides inside every copy of every document carrying it, gets no cache entry, and changes only when you edit whatever holds it.

The format has a hard edge worth knowing first: a data URI is not a file, and plenty of software declines to treat it as one. Mail clients are the usual casualty — an inlined signature that looks right in your editor arrives as an empty box — and a Content-Security-Policy without data: in img-src blocks it just as firmly.

Settle what you are copying, too. The output is a complete data URI, prefix and all — the form an img src or a CSS url() needs. A field expecting raw base64 does not want the data:image/png;base64, prefix, and pasting a full URI where something adds its own gives a string that decodes to nothing.

How it works

Toolvore reads the file you choose with the browser's FileReader, which produces a complete data URI — the data: scheme, the media type, the word base64 and the encoded bytes — without any of it leaving the page. The media type comes from the file's extension rather than its contents, so the result is tested rather than trusted: the URI is loaded into an off-screen image element, and only one the browser genuinely draws is shown to you, so a text file renamed to .png fails there rather than becoming a URI no img can display. The weaknesses follow from the same mechanism. Anything your browser cannot decode — HEIC off an iPhone, a TIFF — is refused, though base64 itself is indifferent to format. Files stop at 20 MB and one image is encoded at a time, so a folder of icons means repeating the job. The size beside the filename is the original file's, not the length of the string you are copying, and there is no download and no line wrapping.

Common use cases

  • Inlining a small logo in an HTML email template
  • Embedding an icon in a CSS background-image rule
  • Sending an avatar to an API that expects base64 in JSON
  • Keeping a single-file HTML report working with no assets folder
  • Dropping an image into a notebook cell with nowhere to host it
  • Storing a signature image in a text-only database column
  • Adding a placeholder graphic to a prototype with no build pipeline

Frequently asked questions

What is a base64 data URI, exactly?

Base64 rewrites arbitrary bytes using 64 printable characters, taking three bytes at a time and emitting four, padding the end with one or two equals signs when the length does not divide evenly. A data URI is the envelope around that: the data: scheme, a media type such as image/png, the word base64, a comma, then the payload. The encoding alone tells software nothing about what it holds; the URI does, which is why a browser given the whole string in an img src draws it in place rather than fetching anything.

Why is the base64 version larger than the image file?

Four characters for every three bytes is a fixed third on top before the prefix is counted, and nothing avoids it — base64 is a transport encoding, not a compression one, so it can only add. Gzip and brotli claw back a useful part of that when the URI sits inside an HTML or CSS file, but never down to the original binary, which PNG or JPEG had already compressed. At small sizes the overhead rarely decides anything; what decides it is that the bytes now travel with the document rather than separately from it.

When is inlining an image a bad idea?

Whenever the image is large, reused, or changes on a schedule of its own. An inlined image has no cache entry, so a logo living in a stylesheet is downloaded again every time anything else in that stylesheet changes, and the same picture pasted into ten templates is ten copies. It cannot be lazy-loaded either, as there is no request to defer — everything inlined is paid for up front, and an image inside render-blocking CSS delays the first paint. Inlining wins only where a round trip would cost more than the bytes do.

Why does my inlined image not appear in email?

Because mail clients decide for themselves what an img src may contain, and several refuse data URIs outright. Gmail's web interface and various Outlook builds are the ones people hit: the image is dropped or shows as an empty frame while identical HTML renders correctly in a browser. Some webmail also rewrites images through a proxy that understands only http addresses. Two approaches survive — a hosted image on a stable https URL, or a real attachment referenced with cid:. Test by mailing yourself in the clients your recipients use.

Is it safe to convert an image to base64 online?

Nothing leaves your machine. The file is handed to the browser's FileReader, the data URI is built in the page, and the preview you see is that same string drawn by an image element — no request carries the picture anywhere, because there is no server in the path to carry it to. That matters more here than for most conversions, because the images people need as base64 are disproportionately scanned signatures, ID photographs, dashboard screenshots and unpublished artwork. A converter that uploads hands all of that to a stranger.

How do I use a data URI in HTML, CSS and JSON?

In HTML the whole string goes into an img element's src attribute exactly as copied. In CSS, wrap it in url(...) for background-image; quotes are optional there, as the base64 alphabet holds no spaces or brackets to confuse the parser. In JSON it is a plain string value needing no escaping. Check what the receiving API wants, though — many accept only the payload and reject the data:image/png;base64, prefix, while others require it. Wherever it goes, keep it on one line: a break inside it is fine for some parsers and fatal to others.

Does converting to base64 reduce image quality?

No. Base64 is a reversible mapping between bytes and characters, so decoding returns the original file exactly, byte for byte — same pixels, same compression artefacts, same embedded metadata. Nothing is resampled and nothing is discarded, which is also why the string can never come out smaller than the file went in, and why encoding and decoding repeatedly costs nothing, unlike re-saving a JPEG. If the string is too long, the fix sits upstream: resize the image to the dimensions it is displayed at, or compress it, then encode the smaller file.

Should I base64 an SVG, or encode it another way?

You can, and it will draw, but base64 is usually the wrong wrapper for an SVG. An SVG is already text, so base64 makes it a third longer for no gain, where percent-encoding the markup instead — escaping the few characters that matter, chiefly the hash and angle brackets — often lands shorter than the original file and stays readable where it sits. Base64 earns its place when a field demands one opaque blob of text. Either way, an SVG loaded through an img src cannot run scripts or fetch external fonts.