Developer tool

File to Base64

Turn any file into Base64 text or a ready-to-paste data URI.

File to Base64 Runs on your device
Drop files here or click to browse
One file of any type
Never uploaded
  • Runs on your device — the file is never sent anywhere
  • No sign-up, no watermarks, no daily quotas
  • Free, with no limit on how often you use it

How it works

Base64 turns a binary file into text so it can travel somewhere only text is allowed: inside an HTML page, a CSS file, a JSON payload, a configuration file, an email. Encoding one on a remote server means uploading the file to get text back, which is a strange trade for something a browser can do instantly.

Data URI or plain

A data URI carries the media type as a prefix, so a browser knows what it is: paste one into an img src or a CSS background and it works with no separate file. Plain Base64 is what you want when something else in your pipeline supplies the type.

It gets about a third larger

Base64 represents three bytes as four characters, so expect roughly a 33% increase plus a little overhead. That is the cost of the format and nothing can avoid it, which is why inlining is best reserved for small assets — icons, small logos, fonts subsets.

When not to inline

A large inlined image makes the HTML or CSS file bigger, uncacheable separately, and slower to parse. The rule of thumb is a few kilobytes: below that, inlining saves a request; above it, a normal file reference is faster.

Going back

The Base64 decoder on this site turns the text back into the original file, and previews it if it is an image.

FAQ

File to Base64 — questions

What is a data URI?

Base64 with the media type attached, so it can be pasted directly into HTML or CSS as if it were a file.

Why is the text bigger than my file?

Base64 encodes three bytes as four characters — roughly a third larger. That is inherent to the format.

Should I inline large images?

No. Below a few kilobytes it saves a request; above that a normal file reference is faster.

Is my file uploaded?

No. It is encoded in your browser.