File to Base64

Convert any file to Base64 encoding

Click or drop any file hereChoose any file

About File to Base64

File to Base64 turns the bytes of any file, whether a PDF, a ZIP, a font, or a recording, into Base64 text. Choose Data URL, which adds the data:<type>;base64, prefix for an src attribute or a CSS url(), or Raw Base64, the payload alone for JSON or an API request. When your browser gives the file no type, the tool reads it from the file's first bytes for common formats such as PNG, JPG, HEIC, PDF, ZIP, or MP4. It only encodes: there is no way back from Base64 to a file on this page. The file never leaves your device.

Example

A text file named hello.txt that contains the word hello and nothing else (browsers give a .txt file the type text/plain):

File content

hello

Result

Data URL:
data:text/plain;base64,aGVsbG8=

Raw Base64:
aGVsbG8=

Downloaded as hello.txt.base64.txt

How to convert a file to Base64

  1. 1Click the dashed area to pick a file, or drop the file on it; on a phone, tap the area.
  2. 2Encoding starts as soon as the file is chosen, and the result shows in the form you picked last, "Data URL" for the first file.
  3. 3Switch to "Raw Base64" if you need the text without the data: prefix.
  4. 4"Copy Base64" puts the whole text on the clipboard; "Download" gives a file named after yours plus .base64.txt.

Formats and limits

Input
One file of any type at a time; an empty file is refused with a message
Output
Data URL or Raw Base64 text, copied or downloaded as a .txt file
File size
The tool sets no size cap; every three bytes of the file become four characters of text
Large results
The box previews the first 100,000 characters, while Copy Base64 and Download give the whole text

Where your file is processed

Your browser's FileReader turns the file into Base64 on your device: the file and its Base64 text are not sent to us, and nothing is kept once you leave the page. When an error is shown, such as an empty file or a file that cannot be read, or when the browser refuses a copy, we receive that message with file names removed, the tool's name, and your browser's name and version.

Frequently asked questions

How much bigger is the Base64 than the file?

About a third bigger, because every three bytes become four characters. Data URL also adds the data:<type>;base64, prefix. The counter above the result gives the exact number of characters for your file and the format you chose.

Why does my data URL say application/octet-stream?

Neither your browser nor the tool recognized the file's type, so the generic type stays. When the browser gives no type, the tool checks the first bytes for common images, audio, video, PDF, Office, archive, and font formats before falling back to it.

Can I turn Base64 back into a file here?

No, this page only encodes. Base64 Encode and Decode turns Base64 back into text and tells you when the bytes are binary rather than text, but it does not rebuild the original file for you to download.

Can I encode several files at once?

No. The tool takes one file at a time, whether you pick it or drop it. Choosing another file replaces the previous result, so copy or download each result before moving on.

Tips and tricks

  • ✓For a picture, Image to Base64 can also write an HTML img tag, a CSS background-image line, or a JSON object.
  • ✓Choose "Raw Base64" before copying when an API field expects only the encoded bytes.