File to Base64 / Data URI Converter
Convert any file, not just images, to a Base64 string or Data URI: PDF, audio, fonts, ZIP and more. You can also paste a Base64 string or Data URI and download it back as a file. For images only, with a preview, use the Image to Base64 Converter; for plain text, try the Base64 Encoder/Decoder.
🔒 Runs in your browser · Your data is never sent to a server
You can also drag and drop any file here
If empty, "file" plus a detected extension is used
Decoded fileThe type was guessed from the first bytes of the data. If it is wrong, type a file name with the right extension.
How to use
- Pick "File to Base64" or "Base64 to File" with the mode switch.
- For "File to Base64", choose or drop a file, pick the output format ("Data URI" or "Base64 only"), then press "Copy".
- For "Base64 to File", paste the Base64 string or Data URI, optionally type a file name, and press "Download as file".
Notes
- The file bytes are encoded as-is, so there is no re-compression or quality loss. Base64 output is about 1.33x (4/3) longer than the original.
- Files over 5 MB show a warning and files over 30 MB cannot be converted. Very long Base64 strings can make copying and pasting slow in the browser.
- "Base64 to File" accepts Base64URL (- and _), mixed line breaks and spaces, and missing padding (=). It also decodes percent-encoded Data URIs such as data:text/plain,Hello%20World.
- For Base64 without a prefix, the type (PDF, ZIP, image, audio, font and so on) is guessed from the first bytes. If it cannot be guessed, the file is saved as .bin, so add an extension in the file name.
- All processing happens in your browser. The file or Base64 string you provide is never sent to a server.
Glossary
Base64
An encoding that turns binary data into a string of letters, digits and a few symbols (A-Z, a-z, 0-9, +, /, =). It is used to embed files in text-only formats such as JSON, email or HTML.
Data URI
A URL such as `data:application/pdf;base64,...` that bundles a MIME type and the content into one string, so data can be handed to the browser without a separate file request.
MIME type
An identifier for a file type, such as `application/pdf` for PDF or `audio/mpeg` for MP3. It tells the browser how to treat the data.
Magic number
A few fixed bytes at the start of a file that identify its format. PDF starts with `%PDF-` and ZIP starts with `PK`. They are used to guess a type when no extension or MIME type is known.
FAQ
What is the maximum file size?
30 MB. A warning appears above 5 MB. Base64 is about 1.33x longer than the original, and strings of tens of megabytes make copying and pasting sluggish in the browser, so use another way to hand over large files.
Can I convert a PDF or audio file to Base64?
Yes. Any file works, not just images: PDF, MP3, WAV, fonts (WOFF/TTF), ZIP and so on. The raw bytes are encoded as a Base64 string or Data URI. For images only, the Image to Base64 tool adds a preview.
The decoded file was saved as .bin. Why?
For Base64 without a prefix, the type is guessed from the first bytes, and unrecognized formats fall back to .bin. Type a file name with an extension, such as "report.pdf", before you download.
What is the difference between Data URI and Base64 only?
A Data URI is a single-line URL with the MIME type, like "data:application/pdf;base64,", and can be used directly in HTML or CSS. Base64 only is just the content, suited to JSON APIs or email attachments, and can be wrapped every 76 characters.
Share this page
