KKwikfig.

Image to Base64 Converter

Convert any file to a data URI in your browser, or decode one back into a file — with exact Base64 character counts and overhead figures, no uploads. Runs entirely in your browser — your numbers never leave this device.

Mode
Choose the file to encode as a data URI
Click to browse, or drag and drop a file here — it never leaves your device.

No file encoded yet. The file is read on this device and turned into a data URI locally — the encoded text is exactly 4 characters for every 3 bytes, padding included.

How it works

Data URI = "data:" + MIME type + ";base64," + Base64(file bytes) | Encoded characters = 4 × ceil(bytes ÷ 3) | Overhead % = (encoded characters ÷ original bytes − 1) × 100, which tends to 33.3% as files grow
The Base64 size overhead — encoded characters = 4 × ceil(bytes ÷ 3)
File size (bytes)Base64 charactersOverhead
3433.3%
8 (a PNG signature)1250.0%
30040033.3%
1,0241,36833.6%
1,048,576 (1 MiB)1,398,10433.3%

Base64 turns binary bytes into text that can travel anywhere text can — inside HTML, CSS or JSON — by re-packing the bytes: every group of 3 bytes (24 bits) is split into four 6-bit characters, with padding characters (=) completing a partial final group. That arithmetic fixes the cost exactly: the encoded form is always 4 × ceil(bytes ÷ 3) characters, about one third larger than the file. This tool reads your file in the browser and shows both numbers side by side — the file's exact byte count, the exact character count of its Base64 form, and the overhead percentage — so the size trade of embedding is a measured fact, not a rule of thumb you have to trust.

Encode mode produces the full data URI (the file's MIME type, the ;base64 flag, and the payload) in a copyable text area, plus ready-made CSS background and <img> snippets with copy buttons. Decode mode runs the other way: paste any data URI and the tool parses its MIME type and encoding, reports the decoded size, previews it when it is an image, and offers the reconstructed file as a download. The parser accepts plain (percent-encoded) data URIs as well as Base64 ones, and says so plainly when what you pasted is not a data URI at all.

Files never leave your device in either direction. Encoding reads the file with your browser's local file reader; decoding parses and rebuilds the file in memory. Nothing is uploaded, stored or logged — pasting a data URI here is exactly as private as pasting it into your own text editor, and the tool works offline.

Worked examples

The smallest real image header

Input
An 8-byte PNG signature (the first 8 bytes of every PNG file)
Working
8 bytes = two full 3-byte groups plus 2 leftover bytes, padded with one =: 4 × ceil(8 ÷ 3) = 12 characters — the well-known string iVBORw0KGgo=. Overhead = 12 ÷ 8 − 1 = 50.0%, the worst case small files always pay.
Result
8 bytes → data:image/png;base64,iVBORw0KGgo= (12 chars, +50.0%)

A 1 MiB photo embedded in CSS

Input
photo.jpg — 1,048,576 bytes
Working
4 × ceil(1,048,576 ÷ 3) = 4 × 349,526 = 1,398,104 characters. Overhead = 1,398,104 ÷ 1,048,576 − 1 = 33.3% — the figure every large file converges to, and the reason embedding suits small icons better than photographs.
Result
1,048,576 bytes → 1,398,104 Base64 characters (+33.3%)

Decoding a pasted data URI

Input
data:text/plain;base64,SGVsbG8=
Working
The parser reads MIME type text/plain and the Base64 flag; the payload is 8 characters with one padding character, so the decoded size is 8 × 3 ÷ 4 − 1 = 5 bytes — the text Hello, offered as a .txt download.
Result
Decodes to a 5-byte text file containing “Hello”

Frequently asked questions

Does the file I encode get uploaded?

No — in either mode. Encoding reads the file locally in your browser and decoding rebuilds the file in local memory; no file, data URI or fragment of one is sent to a server, stored or logged. Disconnect from the network and both modes still work, which is the check you can run yourself.

Why is Base64 always about 33% bigger?

Because of the packing: 3 bytes become 4 characters, a ratio of exactly 4/3, so large files converge to 33.3% overhead. Small files can pay more — an 8-byte file needs 12 characters, +50% — because the last partial group is padded up to a full 4 characters. The tool shows your file's exact figures rather than the average.

When should I embed an image as a data URI at all?

For small, page-critical graphics — a tiny logo, an icon, a background pattern — where saving one network request matters more than the 33% size tax, and where the URI can be cached inside a CSS or HTML file you already ship. For photographs and anything large, a separate image file is smaller and cacheable on its own; embedding a 1 MiB photo adds roughly 350,000 characters to your page.

What is the difference between this and the Base64 Encoder in Developer Tools?

Scope. The developer tool encodes and decodes text, with URL-safe alphabets and a small file mode. This tool is built for files and images: it produces complete data URIs with the MIME prefix, reports exact byte and character counts, generates CSS and <img> snippets, previews decoded images and downloads the decoded file with the right extension.

My pasted URI will not decode — what is wrong?

Usually one of three things: the string does not start with data: (a bare Base64 blob has no MIME header — the developer Base64 tool handles those), the comma separating header from payload is missing, or the payload was truncated when copying, which breaks the final padded group. The tool names a non-data-URI when it sees one and refuses a payload it cannot decode rather than downloading a corrupt file.

Related tools

More in Image Tools · Browse all tools