File to Base64

Convert files to Base64 and data URIs — nothing is uploaded

Runs in your browserUtility03Encoding & Crypto

What is File to Base64?

This file-to-Base64 converter reads a local file in the browser and outputs both the raw Base64 string and a ready-to-paste data URI for HTML and CSS, along with the size overhead the encoding adds. The file is read through the browser File API, so it never leaves your machine.

How to use File to Base64

  1. 1Click "Choose file" and pick any local file — images, PDFs, certificates, and so on.
  2. 2Review the file details and the Base64 length, keeping in mind that encoding inflates the size by roughly 33%.
  3. 3Copy either the plain Base64 string or the data URI with its MIME prefix, whichever your target needs.

How do I do this in code?

Use the tool above for one-off work; for anything you repeat, move it into a script or your project.

# Encode a file as Base64 (on macOS use base64 -i)
base64 -w 0 logo.png > logo.b64

# Decode it back
base64 -d logo.b64 > logo.png

Frequently asked questions

How large a file can I reasonably convert to Base64?+

Stay under a few hundred kilobytes. Base64 grows the payload by about a third and inlined data cannot be cached separately by the browser, so embedding a large image in CSS or JSON usually slows down first paint instead of speeding it up. Inlining pays off only for small assets such as icons and font subsets.

Does this page upload my file anywhere?+

No. The file is read locally into an ArrayBuffer through the File API and encoded in place — the page has no upload endpoint at all. You can confirm this in your browser network panel: no request carrying the file contents is ever made.

Related tools

All tools