Skip to content
Convertto

File to Base64 Converter

Encode any file — image, PDF, video, font, archive — as Base64, a data URI, hex or a byte array.

This encodes any file — image, PDF, video, font, archive or arbitrary binary — into Base64, a data URI, hexadecimal, or a ready-to-paste array for JavaScript, C or Python. The MIME type is detected from the file's magic bytes rather than its extension, and everything is encoded in your browser.

Runs in your browser
File types
Any — 24 formats are identified by magic bytes, the rest encode as raw binary
Output formats
10 — data URI, Base64, Base64url, CSS, HTML, hex, JavaScript, C, Python and JSON
Overhead
Base64 increases size by approximately 33%
Privacy
Runs entirely in your browser — nothing is uploaded
Cost
Free, unlimited, no sign-up

Frequently asked questions

Why is the Base64 bigger than my file?

Base64 represents every 3 bytes as 4 printable characters, so the output is always about 33% larger. That is the price of making binary data safe to put in text-only places such as JSON, HTML and email.

When should I inline an image as a data URI?

For small assets — icons under a few kilobytes, or a font subset — where removing a request matters more than the size increase. For anything larger, a separate file wins because it can be cached, compressed and loaded in parallel.

How is the MIME type detected?

From the file's leading bytes, not its extension. A PNG always starts with the same eight-byte signature, so the type is read from the content itself — which is why renaming a file does not fool it.

How to use the file to base64 converter

  1. 1Select your files — the file stays on your device and is never uploaded.
  2. 2Choose the output as.
  3. 3Enter or paste your mime type override.
  4. 4Set the wrap lines at.
  5. 5Turn "Include a size warning" on or off as needed.
  6. 6Press Run, then download the result when it is ready.

Embed this tool

Put the working file to base64 converter on your own site. It runs in your visitors' browsers exactly as it does here — free, no account, nothing uploaded.

Share this tool

Last updated

More encoders & decoders