Encode File to Base64
Encode a local file or URL content to Base64 in your browser. Supports custom alphabets, Base64URL, MIME, UTF-7, and IMAP variants. Read more
Encode a file as Base64
This tool reads a local file or URL resource and represents its exact bytes as Base64 text. Local files are processed by the page in your browser. The result can be copied or downloaded for text-based formats that need to carry binary data.
Base64 is a reversible encoding, not encryption. Anyone with the encoded text can recover the original bytes without a key. Standard Base64 is defined by RFC 4648.
How to convert a file to Base64
- Select a local file or switch to URL input.
- Choose the Base64 format required by the receiving application.
- Select line-break behavior when using a format that supports wrapped output.
- Encode the file, then copy or download the Base64 result.
Base64 usually increases the data size by roughly one third, with a small additional effect from padding or inserted line breaks. It is suitable for compatibility and transport, but it does not compress the file.
Choosing a Base64 file format
- RFC 4648 uses the standard alphabet with
+and/and=padding when needed. - RFC 4648 URL Safe uses
-and_where URL or filename compatibility is required. - RFC 2045 (MIME) wraps output at 76 characters; choose CRLF for conforming MIME output or LF only when a Unix-oriented consumer requires it.
- RFC 2152 (UTF-7) omits Base64 padding, while RFC 3501 (IMAP) also replaces
/with,; these options encode raw bytes with those alphabets and do not create a complete UTF-7 string or IMAP command. - Custom accepts a specific 64-character alphabet required by another implementation.
The decoder must recognize the compatible alphabet and padding rules. Choose the format named by the target protocol rather than selecting one based only on appearance. For large files, the result may be available only through Download instead of being rendered in the output panel.
Base64 file FAQ
Does Base64 preserve the original file?
Yes, when the Base64 text is complete and decoded correctly, it reproduces the original byte sequence. The filename and external filesystem metadata are not inherently stored in ordinary Base64 text.
Can I put the result directly in a data URL?
The Base64 payload can be used in a correctly constructed data URL, but a data URL also needs the appropriate media type and ;base64 marker. This tool outputs the encoded payload rather than inferring every surrounding format.
How do I restore the file?
Use the Base64 to File tool and provide the desired output filename. For short text values, use Base64 Decode.