File to Base64 Converter

Encode any file, whether a PDF, image, font, audio clip, ZIP or document, as a Base64 string or ready-to-use data URI. Copy it into JSON, HTML, CSS, emails or API requests in one click.

  • 100% free
  • No sign-up
  • Private & local
  • Works on mobile
Drop any file hereor browse files · Any file type · multiple files OK
Options

Private by design: your files are processed locally in your browser and are never uploaded to any server.

What Is a File to Base64 Converter?

A file to Base64 converter encodes the binary contents of a file as a string of plain text characters using the Base64 scheme. Binary files such as PDFs, images, fonts and audio contain bytes that can't safely travel through text-based systems. Base64 encoding solves this by representing every byte with characters from a 64-symbol alphabet that is safe everywhere, including JSON, XML, HTML, CSS, email bodies, URLs, environment variables and database text columns.

This tool reads your file locally and produces Base64 in the exact format you need: raw Base64, a complete data URI with the correct MIME type, a JSON object, a ready-made HTML tag or a CSS url(). It's free, works with any file type, and never uploads your data.

How to Encode a File to Base64

  1. Choose your file(s) by dropping them onto the upload area or clicking to browse.
  2. Pick an output format: plain Base64, data URI, JSON, HTML or CSS.
  3. Set wrapping if needed. 76 characters per line matches MIME email rules, and 64 matches PEM certificates.
  4. Copy or download the encoded text. With several files, click a file in the list to show its output.

Output Formats

FormatExampleUse it for
Plain Base64JVBERi0xLjcK...APIs, databases, config values
Data URIdata:application/pdf;base64,JVBERi...Embedding files in HTML, CSS, Markdown
JSON{"name":"a.pdf","type":"application/pdf","data":"..."}File uploads to JSON APIs
HTML<img src="data:image/png;base64,...">Self-contained web pages and emails
CSSurl("data:image/svg+xml;base64,...")Background images, icons, web fonts

Features

  • Any file typePDF, JPG, PNG, SVG, WOFF2, MP3, MP4, ZIP, DOCX and more.
  • Correct MIME typesData URIs use the MIME type detected from the file's contents.
  • Batch encodingEncode several files and switch between their outputs.
  • Line wrappingOutput compliant with MIME (RFC 2045) and PEM formats.
  • Base64URLURL-safe output without +, / or padding.
  • PrivateFiles are read in your browser and never uploaded.

When Should You Use Base64?

  • Sending files through JSON APIs, for example uploading a PDF or image to a REST endpoint that expects a Base64 field.
  • Embedding small assets such as icons, logos and fonts directly in HTML or CSS to save extra HTTP requests.
  • Email templates that embed images inline.
  • Storing binary data in text systems such as environment variables, YAML configs, spreadsheets or text columns.
  • Testing and debugging API payloads and webhooks that carry files.

Keep in mind: Base64 makes data about 33% larger, and embedded data can't be cached separately by browsers. For large images on websites, linking to the file is usually better than embedding it.

Using Base64 Data URIs in HTML and CSS

A data URI embeds a file directly in a web page. For example, <img src="data:image/png;base64,iVBORw0..."> shows an image without a separate request, and background: url("data:image/svg+xml;base64,...") does the same in CSS. This works well for tiny icons, logos in email signatures and self-contained single-file HTML reports. Keep embedded assets small, ideally under 10–20 KB, because large data URIs bloat your HTML and cannot be cached separately by browsers.

Frequently Asked Questions

Is this File to Base64 converter free?

Yes. It is completely free, works with any file type and requires no account.

Can I get Base64 without the data: prefix?

Yes. Choose "Plain Base64" as the output format to get just the encoded string.

Does the tool work offline?

Once the page has loaded, encoding runs entirely in your browser and needs no internet connection.

Can I encode several files at once?

Yes. Drop multiple files, then click any file in the list to show and copy its Base64 output.

Which MIME type is used in the data URI?

The browser-reported type is used, with the file's magic bytes as a fallback, so PDFs, images, fonts and audio get the correct MIME type.

Why is the Base64 output bigger than my file?

Base64 represents every 3 bytes with 4 characters, so encoded data is about 33% larger than the original, plus a little more if line breaks are added.

Is Base64 encryption?

No. Base64 is an encoding, not encryption. Anyone can decode it, so never rely on Base64 to protect sensitive data.

Is there a file size limit?

There is no fixed limit, but very large files (hundreds of MB) produce huge text that is slow to copy and display. For those, download the output as a .txt file.

How do I decode Base64 back to a file?

Use our Base64 to File converter, which detects the file type automatically and lets you download the original file.

Are my files uploaded?

No. Encoding happens entirely in your browser.