Skip to content

File to Base64 Converter

Drop a file and get its Base64 string or a data: URL you can paste into HTML, CSS, JSON or an API request.

Processed locally in your browser

Options

What is File to Base64 Converter?

Base64 turns raw bytes into printable text, which lets you embed a file inside a text-only format: an <img src="data:…"> tag, a CSS url(), a JSON field or an e-mail body. A data URL adds the MIME type in front: data:image/png;base64,iVBORw0…

This tool reads your file in chunks and encodes it locally, so nothing is uploaded. You can choose plain Base64 or a data URL (the MIME type comes from the file or from its magic bytes), wrap lines every 76 (MIME) or 64 (PEM) characters, or switch to the URL-safe alphabet. The result can be copied or downloaded as a text file.

How does it work?

  1. Drop a file (up to 50 MB) on the drop zone.
  2. Pick "Base64 text" or "data: URL" and, if needed, line breaks or the URL-safe alphabet.
  3. Copy the result or download it as a .txt file.
  4. To go back to a file, paste the text into the Base64 to File tool.

Common use cases

  • Inlining a small icon or logo in HTML or CSS to save an HTTP request.
  • Sending a PDF or image inside a JSON API payload that only accepts text.
  • Embedding a font or image in an e-mail template or a single-file HTML page.
  • Preparing test fixtures where a binary file must live in a source-code string.

Examples

Drop a file and get its Base64 string or a data: URL you can paste into HTML, CSS, JSON or an API request.

Privacy

File to Base64 Converter runs entirely in your browser. The text or files you provide are processed on your device and are not uploaded, logged or stored on our servers.

Limitations

Base64 makes data about 33% larger, so it suits small files; large data URLs slow down pages. Base64 is an encoding, not encryption. Files are limited to 50 MB in this tool.

Frequently asked questions

How much bigger does a file get in Base64?

About one third: every 3 bytes become 4 characters, so a 3 MB file becomes roughly 4 MB of text.

What is a data URL?

A URL that contains the file itself, written as data:<mime>;base64,<data>. Browsers can display it directly without a separate download.

When should I use the URL-safe option?

When the Base64 goes into a URL or file name: it replaces + and / by - and _ and drops the "=" padding. Regular data URLs need the standard alphabet.

More tools in File Tools →