File to Base64 Converter

Convert an image, PDF or any file to Base64 or a data: URI in your browser – no upload. Optional URL-safe alphabet, 76-char wrap, copy or download as .txt.

Runs entirely in your browser. Your data is never uploaded.

What is Base64 File Encode?

Reads a file from your device and encodes its exact bytes as Base64, either as plain Base64 or as a ready-to-use data:<type>;base64,… URI. The file never leaves your browser.

How to use Base64 File Encode

  1. Click the file area and choose a file (any type).
  2. Pick the Output format: Plain Base64 or Data URI.
  3. For plain Base64 you can enable URL-safe alphabet or Wrap lines at 76 characters (MIME).
  4. Check the file name, type, size and Base64 length, then Copy or Download .txt.

Example

Input
encoding-hello.txt (13 bytes: Hello, World!)
Output
SGVsbG8sIFdvcmxkIQ==

With Data URI format: data:text/plain;base64,SGVsbG8sIFdvcmxkIQ==

When to use Base64 File Encode

Use it to inline small images, fonts or icons in CSS/HTML, to send files through JSON APIs or to paste attachments into test fixtures. Avoid inlining large files: Base64 is about 33% larger and cannot be cached separately by the browser.

How Base64 File Encode works

The file is read as an ArrayBuffer and its bytes are encoded with the RFC 4648 Base64 alphabet (3 bytes → 4 characters). The data URI uses the MIME type reported by the browser, or one detected from the file’s magic bytes when the browser does not know it. Images also get a preview.

Common Use Cases

  • Embedding a small PNG or SVG icon as a CSS background data URI
  • Sending a PDF or image in a JSON request body
  • Creating fixtures for unit tests
  • Pasting a certificate or key file into a config that expects Base64

Security Note

Files are processed entirely in your browser. Base64 output is not encrypted – anyone can turn it back into the file.

FAQs

Is my file uploaded?

No. It is read and encoded locally with JavaScript; nothing is sent to a server.

Is there a size limit?

Only your device memory. Files of several megabytes work, but the text output becomes very long; inline data URIs are best kept small.

Which MIME type is used in the data URI?

The type your browser reports for the file. If it is empty, the tool detects common types (PNG, JPEG, PDF, ZIP…) from the first bytes.

Explore more categories