The encoding is the easy part
Converting a file to base64 takes four lines of code, and every tool that does it hands back a wall of text with no further comment. That is the problem: the conversion always succeeds, so nothing tells you that inlining a 200 KB photograph into a stylesheet is a self-inflicted performance problem.
The 33% inflation is fixed and unavoidable — base64 encodes 3 bytes as 4 characters. What varies is whether that trade is worth one fewer request, and past a few kilobytes it stops being worth it. This tool gives the encoded size and the reasons, then lets you decide.
Questions people ask
Straight answers. Each one links directly: copy the address after opening it.
When should I inline a file as a data URI?
When it is small, used in one place, and self-contained — a single icon in an inline style block is the textbook case. Roughly 2 to 4 KB is the sensible ceiling. The saving is one fewer HTTP request; the cost is a flat 33% size increase plus the loss of caching, and above a few kilobytes the cost wins.
Why does base64 make files 33% bigger?
Because it encodes every 3 bytes of binary as 4 ASCII characters, so the ratio is fixed at 4:3 regardless of content. Compression recovers some of that in transit but less than you would expect, since base64 deliberately destroys the byte patterns a compressor looks for. The figure shown here is the real encoded length, not an estimate.
What do I lose by inlining an image?
Caching, first: an external file is fetched once and reused across every page, while an inlined one is re-downloaded with every document or stylesheet that embeds it. You also lose srcset and responsive images, lazy loading, and any CDN image optimisation, because there is no URL left for the browser to negotiate over. In a stylesheet there is a third cost — the base64 is render-blocking, and one unrelated CSS edit invalidates the cached copy of every asset embedded alongside it.
Does this handle non-English filenames and content?
Yes. The common shortcut for this conversion breaks on any byte above 0x7F and blows the call stack on large files. This uses the native Uint8Array base64 encoder where the browser has it, with a chunked fallback everywhere else.
Is my file uploaded?
No. The file is read into memory in your browser and encoded there. Nothing is sent anywhere, which also means there is no size limit beyond your own available memory.