What is File to Base64 Converter?
This file to Base64 converter works with any kind of file, in both directions. In Encode mode, choose a file up to 25 MB, whether a document, archive, font, image, certificate or binary, and you get its contents as a Base64 string, ready for a JSON field, an API request, a database column or an environment variable.
In Decode mode, paste Base64 data and download it as a file. The tool detects common file types from the data itself (PNG, JPEG, GIF, PDF, ZIP and gzip) or from a data: URI prefix, suggests the right extension, and lets you set the file name before downloading.
How to use File to Base64 Converter
- Choose Encode to turn a file into Base64, or Decode to turn Base64 into a file.
- To encode, select a file up to 25 MB; copy the Base64 output.
- To decode, paste the Base64 string or data URI; the detected file type is shown.
- Adjust the file name and extension if needed, then click Download Decoded File.
Key features
- Encode any file up to 25 MB to Base64
- Decode Base64 back to the original file
- Automatic detection of PNG, JPEG, GIF, PDF, ZIP and gzip
- Uses the MIME type from data: URIs
- Custom file name and extension for downloads
- Runs entirely in your browser
Common use cases
- Sending files in JSON API requests that expect Base64
- Storing certificates and keys in environment variables or Kubernetes Secrets
- Saving Base64 attachments returned by email and document APIs
- Recovering files stored as Base64 in databases
- Embedding small binaries in configuration or test fixtures
Technical details & standards
Encoding reads the file locally with the FileReader API and Base64-encodes its bytes (RFC 4648), making the result about 33% larger than the file. Decoding turns the Base64 back into the exact original bytes.
The file type is identified from its magic bytes, the signature at the start of every file: 89 50 4E 47 for PNG, FF D8 FF for JPEG, 47 49 46 38 for GIF, 25 50 44 46 (%PDF) for PDF, 50 4B 03 04 for ZIP (and Office files, which are ZIP-based) and 1F 8B 08 for gzip. If a data: URI prefix is present, its MIME type is used. Other types default to a .bin file that you can rename. Files never leave your device.
Frequently asked questions
How do I convert Base64 to a file?
Choose Decode and paste the Base64 string. The tool detects the file type where it can; set the name and extension, then click Download Decoded File.
How do I know what type of file Base64 data contains?
Look at the first bytes once decoded: each format has a signature. The tool checks for PNG, JPEG, GIF, PDF, ZIP and gzip automatically, and a data: URI prefix states the MIME type directly.
Is there a file size limit?
Encoding accepts files up to 25 MB. Base64 makes data about a third larger and is held in memory, so very large files are better transferred as binary.
How do I convert a file to Base64 on the command line?
On Linux run base64 -w 0 file.pdf, on macOS base64 -i file.pdf, and in PowerShell [Convert]::ToBase64String([IO.File]::ReadAllBytes("file.pdf")).
Is my data safe?
Processing happens locally in your browser. Tool input is not sent to CodeUnpack servers.
Does it work offline?
Once the page has loaded, this tool can process input without an internet connection.