Base64 File Converter

Convert Base64 ↔ files locally

Preview images, download files, and copy Base64 — all in your browser

Last updated: January 25, 2026
Frank Zhao - Creator
CreatorFrank Zhao

Base64 to file

File to base64

Drag and drop a file here, or click to select a file

Introduction / overview

This tool does two things: it turns an uploaded file into a Base64 string (useful for copy/paste workflows), and it turns a Base64 string back into a downloadable file. If the Base64 contains a data-URI prefix (or looks like a common file signature), the tool can infer the file type.

Privacy note

Conversions happen in your browser. Nothing is uploaded by this page. (Just remember: if you paste Base64 into a third-party site, that’s a separate decision.)

Base64 is an encoding, not encryption. If you need confidentiality, use real encryption (for example, our Encrypt / Decrypt Text), and treat Base64 as a packaging format.

How to Use / Quick Start

A) Base64 to file (download)

1

Optional: set a filename and extension

If you leave Extension blank, the tool tries to infer it from the Base64 (data URI or common file signatures).

2

Paste your Base64 string

You can paste raw Base64 or a full data URI (for example, data:image/png;base64,...) — both are supported.

3

Preview (images only) and download

Use “Preview image” to sanity-check pictures. Then use “Download file” to save it.

B) File to Base64 (copy/paste)

1

Upload the file

Drag and drop a file, or click Browse files to select one.

2

Copy the Base64 result

The output is a data URI (it includes the MIME type prefix). This is convenient for HTML/CSS and quick sharing.

3

Use it where you need it

Paste into HTML, a config file, a JSON payload, or an email (depending on your workflow).

Quick sanity check: does the size look reasonable?

Base64 increases size by about one third. A handy rule of thumb is:

L=4n/3L = 4\,\lceil n/3 \rceil\approx1.33n1.33\,n

where nn is the input size in bytes and LL is the Base64 length in characters (not counting line breaks).

Real-World Examples / Use Cases

Example 1: Embedding a small image in HTML

Background: you want a single self-contained HTML file. Upload an image, then copy the data URI into an img\text{img} tag.

Size sanity check

Suppose the image is n=10,240 bytesn = 10{,}240\ \mathrm{bytes} (10 KB).

LL==410240/34\,\lceil 10240/3 \rceil==13,65613{,}656 chars (approx.)\text{ chars (approx.)}

Result: the Base64 string will be longer than the original file (that’s expected).

Example 2: Recovering a PDF from Base64

Background: an API response contains a Base64 payload. Paste it into “Base64 to file”. If the Base64 starts with a known PDF signature, the tool can infer the MIME type and suggest an extension.

How to interpret the output

  • If “Preview image” fails, it may simply be a non-image file (that’s normal).
  • “Download file” should still work as long as the Base64 is valid.

After downloading, you can validate the file type further using our PDF Signature Checker.

Example 3: Debugging an API that returns Base64

Background: you’re not sure whether an API returns a raw Base64 payload or a full data URI. Paste it into the Base64 field. If it includes a prefix like data:...;base64,\text{data:...;base64,}, the tool can use that to decide the file type.

If you only need Base64 text decoding (not files), use our Base64 String Encoder/Decoder.

Common Scenarios

Inline assets in HTML/CSS

Turn small images into data URIs for a single-file demo page or an email template.

API troubleshooting

Decode Base64 responses into real files so you can open them and inspect the content.

Database payloads

Convert a file to Base64 before storing it in a JSON field (only when you really must).

Email attachments (legacy)

Understand Base64 strings you see in raw emails and MIME parts.

Quick previews

Paste Base64 for an image and preview it before downloading.

File-type guessing

When the extension is unknown, let MIME inference suggest an extension, then verify by opening the file.

When it may not apply: if your data needs to be URL-safe, you likely want Base64URL. Use our Base64 String Encoder/Decoder and enable URL-safe mode.

Tips & Best Practices

Practical tips

  • If your Base64 includes whitespace or line breaks, paste it anyway — Base64 often travels with formatting.
  • Prefer leaving Extension blank if your Base64 is a full data URI. The MIME type is already there.
  • For very large files, Base64 can be memory-heavy. If you can, use direct uploads instead of encoding.
  • If a decoded file won’t open, verify the source (wrong MIME type, truncated payload, or URL-safe Base64).

Common mistakes to avoid

  • Mixing Base64 and Base64URL: Base64URL replaces ++ and // with URL-safe characters.
  • Truncated payloads: if you copied from logs, ensure you didn’t cut off the end (padding matters).
  • Assuming Base64 is secure: it’s reversible by design.

Calculation Method / Formula Explanation

Base64 converts every 3 bytes into 4 printable characters. That’s why Base64 is larger than the original bytes.

L=4n/3L = 4\,\lceil n/3 \rceil

nn = input bytes, LL = Base64 length (characters)

Why padding exists

If the byte length is not a multiple of 3, Base64 adds padding characters so the output length is a multiple of 4. In many contexts, you’ll see one or two == characters at the end.

LL\equiv0 (mod 4)0\ (\mathrm{mod}\ 4)

Related Concepts / Background Info

Data URIs

A data URI embeds the MIME type and the Base64 payload in one string. Conceptually it looks like:data:mime;base64,payload\text{data:}\langle\text{mime}\rangle\text{;base64,}\langle\text{payload}\rangle.

Base64 vs Base64URL

Base64URL is a URL-safe variant that avoids characters that often need escaping. If you’re dealing with tokens (JWT parts, URL parameters), prefer Base64URL.

Frequently Asked Questions (FAQs)

Why is the Base64 string so long?

Base64 expands data: roughly 4/3\approx 4/3 of the original byte length. Use L=4n/3L = 4\,\lceil n/3 \rceil as a size estimate.

Can I paste a full data URI?

Yes. Strings that start with data:...;base64,\text{data:...;base64,} are supported.

Why doesn’t image preview work for my Base64?

Preview only makes sense for images. If your Base64 is a PDF, ZIP, or other type, downloading is the right path.

Is Base64 the same as encryption?

No. Base64 is reversible encoding. For encryption, use Encrypt / Decrypt Text.

My Base64 is URL-safe (it uses '-' and '_'). What should I do?

That’s Base64URL. Decode it with our Base64 String Encoder/Decoder (URL-safe mode), then use the result as needed.

Limitations / Disclaimers

What this tool does not guarantee

  • MIME inference is best-effort. Unknown signatures may not auto-detect.
  • Very large inputs can hit browser memory limits.
  • This is not a security product. Don’t treat Base64 as protection.

External References / Sources

Base64 File Converter - Base64 ↔ File (Preview & Download)