LazyTools

🔒 Every tool runs in your browser — the files and values you enter are never uploaded to any server. How it works

📥 File to Base64 Encoder

Turn any file into Base64 text, or a full data URI you can paste straight into CSS or HTML — encoded locally, never uploaded.

Base64 turns any file’s bytes into text so it can be embedded in JSON, HTML, CSS or a data URI. Output is about 33% larger than the file. 🔒 Encoding runs entirely in your browser — the file is never uploaded.

Rate this tool:
Anonymous — no account, no identifier

How the file to base64 encoder works

The tool reads your file as raw bytes with the browser’s File API and encodes those bytes into Base64 — the text-safe representation that maps every 3 bytes to 4 characters. Tick "data URI" to wrap it as data:<mime>;base64,<data>, the form you can drop directly into an <img src>, CSS background or JSON field. Encoding is done in chunks so even multi-megabyte files don’t overflow the browser, and nothing is sent anywhere.

Embedding a small asset as a Base64 data URI saves an HTTP request, which is handy for icons, fonts and tiny images inlined into CSS or HTML email. The trade-off is size: Base64 is about 33% larger than the original bytes and isn’t cached separately, so it’s best for small assets, not large media. Because the file never leaves your browser, it’s safe for private documents too.

Frequently asked questions

How do I convert a file to Base64?

Choose the file and the tool outputs its Base64 encoding instantly. Tick "data URI" to also get the data:…;base64,… wrapper you can paste directly into HTML or CSS. Copy the result with one click.

What is a data URI?

A way to embed a file’s contents inline as text, in the form data:<mime-type>;base64,<encoded-data>. Browsers treat it like a real file, so you can use it as an image source or CSS background without a separate request.

How much bigger does Base64 make my file?

About 33% larger, because every 3 bytes become 4 text characters. That overhead is why Base64 embedding suits small assets (icons, small images, fonts) rather than large files.

Is there a file size limit?

The practical limit is your device’s memory, since everything happens locally. Small and medium files encode instantly; very large files use more memory because the whole Base64 string is held in the page.

Is my file uploaded?

No — the File API reads it in your browser and the encoding happens on your device. The file and its Base64 are never transmitted, so it’s safe for private content and works offline.

Related file converters

From the blog