Upload a file
  1. base64hub
  2. File tools
  3. File to Base64

File to Base64

Drop any file, or several, and copy the Base64 as a plain string, a data URI or a JSON object. Large files are read in chunks inside your browser, and nothing is uploaded.

Free no sign-up, no limits Local nothing uploaded Batch several files, one JSON array Updated Oct 27, 2026
Drop files here, paste, or pick them
Input –Output –Size –

Processed in your browser. This page cannot send your data anywhere – how we know

How to convert a file to Base64

  1. Drop one or more files on the box, use the file picker, or paste copied files with Ctrl+V.
  2. Choose Output as: Plain Base64 (the default here), Data URI, HTML <a download>, JSON and the image and font wrappers.
  3. Optional: URL-safe swaps + and / for - and _; Wrap at 76 breaks lines for MIME email.
  4. Copy output, or Save as .txt to get filename.ext.b64.txt.

With several files, a list shows each name with its original and encoded size. Show displays one result, and Copy all as JSON copies every file as an array of {name, type, size, data} objects. That is quick to paste into a fixture file or a seed script.

What the output options mean for non-image files

Output asResult for report.zipUse it for
Plain Base64UEsDBBQAAAAI...API fields, environment variables, config values
Data URIdata:application/zip;base64,UEsDBBQA...URLs in HTML or JavaScript
HTML <a download><a href="data:application/zip;base64,..." download="report.zip">report.zip</a>a self-contained download link
JSON{"name": "report.zip", "type": "application/zip", "size": 323, "data": "UEsDBBQA..."}test fixtures, your own upload endpoints

The JSON keys are fixed (name, type, size, data). If an API expects other names, rename them after pasting. size is the original file size in bytes, which lets the receiver check that the decoded length matches.

The MIME type in the data URI and the JSON type comes from your browser. If the browser does not know the file, the tool guesses from the extension, and if that fails too it uses application/octet-stream. Only the label depends on this; the Base64 is the same either way.

Binary files in CI secrets and config

A common reason to encode a whole file is a secret store that only holds text: CI variables, .env files, Kubernetes Secrets. Signing keystores, certificates and service-account files go in as one Base64 line and are restored in the pipeline:

echo "$KEYSTORE_B64" | base64 -d > release.keystore

Keep Wrap at 76 off for this. A value with line breaks often gets mangled by the secret UI or the shell. Kubernetes stores every value under data: this way, and the Kubernetes Secret decoder reads them back.

Know what you encoded from the first characters

The first bytes of most file formats are a fixed signature, so the start of the Base64 tells you the type without decoding. A few common ones:

File typeBase64 starts with
PDFJVBERi0
ZIP, DOCX, XLSX, PPTX, JAR, APKUEsDB
gzip (.gz, .tgz)H4sI
7-ZipN3q8ryc
Windows EXE or DLLTVqQ (most files), always TV
Linux ELF binaryf0VMRg
SQLite databaseU1FMaXRlIGZvcm1hdCAz
MP3 with ID3 tagSUQz
PNGiVBORw0KGgo
JSON objecteyJ (for {")

A longer list is on common Base64 prefixes. When you decode with Base64 to File, the type is detected the same way.

Size, memory and large files

Base64 output is 4/3 of the input, rounded up to a multiple of 4 characters. A 1 MB file becomes 1,398,104 characters, and with Wrap at 76 another 18,396 newline characters are added. The counters under the output show both sizes and the overhead in percent.

Everything runs in the browser tab, so the practical limit is your device’s memory:

  • The text box shows the first 4 MB of output; Copy output and Save as .txt always use the full result.
  • Copy output is disabled for output above roughly 48 MB.
  • Files larger than about 48 MB are encoded in chunks and the result is offered only through Save as .txt.

If a file is that big, ask whether Base64 is the right transport. A multipart upload or a direct binary transfer avoids the 33% overhead and the memory spike on both ends. The size calculator shows the encoded size before you start.

Encode a file from the command line or in code

Linux, with GNU coreutils (-w 0 disables the default 76-character wrapping):

base64 -w 0 report.zip > report.zip.b64

macOS (base64 there does not wrap by default):

base64 -i report.zip -o report.zip.b64

Windows PowerShell:

[Convert]::ToBase64String([IO.File]::ReadAllBytes("C:\data\report.zip")) | Set-Content report.zip.b64

Python:

import base64
from pathlib import Path

encoded = base64.b64encode(Path("report.zip").read_bytes()).decode("ascii")

For streaming large files without loading them into memory, see Base64 in Python, Node.js, Java and PHP.

Common problems

  • Line breaks in the output. GNU base64 wraps at 76 characters by default, openssl base64 at 64, and certutil -encode adds header lines too. Many JSON APIs and environment variables need a single line. Use -w 0, openssl base64 -A, or this tool with wrapping off.
  • application/octet-stream in the data URI. The browser did not know the type and the extension was not in the tool’s list. The bytes are still correct; replace the MIME type in the prefix if the receiver cares.
  • Copy output is grayed out. The result is over the copy limit of roughly 48 MB. Save as .txt still works, and most tools that need the string can read it from a file.
  • The JSON has "data": null for one file. In a batch, files over about 48 MB are encoded in chunks for download only, so Copy all as JSON leaves their data out. Encode that file on its own and save it as .txt.
  • Decoded file is smaller than the original. The string was truncated. Compare the decoded length with the size value in the JSON output.
  • Garbled output when the input was text. Base64 keeps the bytes as they are, including the original character encoding. A UTF-16 text file decodes to UTF-16, not UTF-8. For text you type in, use Text to Base64, which lets you choose the charset.

FAQ

What types of files can I convert to Base64?

Any file. Base64 encodes bytes and does not care what they mean, so executables, archives, databases and documents work the same way as text. Format-specific pages such as PDF to Base64 only add hints for that format.

Is there a file size limit?

There is no fixed limit, since the work happens in your browser. Output up to about 48 MB can be copied; beyond that use Save as .txt. Files above roughly 48 MB are encoded in chunks and only offered as a download.

How do I encode a file to Base64 on Windows without extra tools?

PowerShell can do it in one line: [Convert]::ToBase64String([IO.File]::ReadAllBytes("C:\path\file.bin")). certutil -encode also works, but it adds -----BEGIN CERTIFICATE----- lines and wraps the output, which you then have to strip.

Which MIME type does the data URI use?

The type your browser reports for the file. If it reports none, the tool guesses from the extension and falls back to application/octet-stream. Edit the prefix by hand if the receiver needs a specific type.

How do I decode the Base64 back into a file?

Use Base64 to File. It detects the file type from the decoded bytes and suggests a matching extension.