b2KIT

Base64 File Encoder

Encode any file to a Base64 string and decode Base64 data back to the original file format.

Tested tool guide Tested browser tools Checked August 16, 2026

What Base64 File Encoder does, with a checked example

This tool converts a file into a Base64 string that you can copy, and converts Base64 text back into a downloadable file. The conversion happens entirely in your browser; nothing is uploaded. The common surprise is that Base64 output is about 33% larger than the original file, and the decoded file is byte-for-byte identical to the original only if the Base64 string was generated from the same file with correct padding. If you paste encoded text from another source, watch for line breaks or extra whitespace, which can corrupt decoding.

Worked example

A concrete input and expected output from the current implementation.

Input

SGVsbG8sIHdvcmxkIQ==

Expected output

a file download named something like 'decoded.bin' containing the bytes 'Hello, world!'

The Base64 string decodes to the ASCII bytes for the message. The tool offers the decoded bytes as a downloadable file, because Base64 represents binary data that may not be text.

How the result is produced

1

File to Base64

You select a file from your computer. The tool reads the entire file into memory, converts three bytes at a time into four 6-bit values, and maps those values to the Base64 alphabet. It adds '=' padding so the result length is a multiple of 4. The resulting string is shown in a text box for copying.

2

Base64 to file

You paste a Base64 string into the input. The tool validates the characters and padding, then reverses the mapping to reconstruct the original bytes. It wraps the bytes in a Blob and offers them as a download. If the input is not valid Base64, the tool errors and does not produce a file.

Good uses

  • Embedding a small image or font directly into an HTML or CSS file using a data URI.
  • Transmitting a binary file through a channel that only handles text, like a JSON payload or an email body.
  • Checking whether a Base64 string you received actually corresponds to the file you expect, by decoding and inspecting the result.

Limits and checks

  • The output string is not compressed; it is always about one-third larger than the original binary file, so it may be impractical for large files.
  • Decoding a Base64 string that includes line breaks or spaces may fail unless the tool strips them, which it may not do automatically. Check for extra whitespace.
  • The tool works only in the browser and needs enough memory to hold the entire file plus its Base64 representation, so very large files (hundreds of MB) could slow down or crash the tab.

Common questions

Is the decoded file always identical to the original?

Yes, if the Base64 string came from that exact file and has no extra whitespace or incorrect padding. Base64 is a lossless encoding, so decoding restores every byte. But if you copy the string from a source that wrapped lines, you may need to remove those line breaks first.

Can I encode a large video file?

Technically yes, but the resulting string will be about one-third larger than the video, and the tool loads the whole file into memory. For a 500 MB video, expect a 667 MB string and significant memory use. For very large files, consider a streaming or server-side solution instead.

References and verification

The example and behavioral notes were checked against the browser implementation. Standards and primary references below define the relevant format, formula, or platform behavior.

Related Tools