File to Base64 Converter
Encode any file to a Base64 string and data URI, with ready-to-paste snippets.
Your files are processed on your device and are never uploaded.
Turn any file – an image, PDF, sound, font, ZIP or anything else – into a Base64 string you can paste into code, JSON, XML or an email. The tool gives you the plain Base64 string and a full data URI, plus ready-to-paste HTML tags when the file is an image, PDF, audio, video or font, each with its own Copy button.
Encoding happens in your browser, byte for byte. Nothing in the file changes, and decoding the string later gives you back exactly the same file.
How to Convert File to Base64
- Choose any file: Click the box above or drag the file onto it.
- Wait a moment: The file is encoded right away – usually in well under a second.
- Pick the snippet you need: Use the HTML or CSS code to embed the file, the data URI wherever a URL is expected, or the plain string for JSON and APIs.
- Copy or download: Click Copy, or save the text as a .txt file. Click Choose another to encode the next file.
Where Base64 File Is Useful
- Sending a file inside a JSON API request or webhook
- Storing a small file in a database text column or config file
- Embedding a tiny asset straight into HTML or CSS
- Attaching a file to a MIME email by hand
Data URI or Plain String?
The plain Base64 string is only the encoded data. A data URI adds a short prefix such as data:image/png;base64, that tells the browser what kind of file it is. HTML and CSS need the data URI. Most JSON APIs want the plain string – check the API documentation if you are not sure.
Some systems, mainly email (MIME), expect the string split into lines. Tick Wrap the plain Base64 at 76 characters for that. Leave it off for code and APIs, where line breaks can break the value.
Keep Embedded Files Small
Base64 stores every 3 bytes as 4 characters, so the text is about 33% larger than the file. The tool shows the exact size of your string. An embedded file also cannot be cached on its own, so it is downloaded again with every page that contains it. Base64 suits small assets best – icons, logos, short sounds and small fonts. For big files a normal link loads faster.
Files up to 100 MB can be encoded. Above 5 MB the tool warns you, because strings that long make HTML and CSS files slow to load.
Private and Free
Your file is read and encoded on your own device. It is never uploaded, so the tool is safe for private documents and unreleased designs. Remember that Base64 is not encryption – anyone who has the string can decode it.
Need to go the other way? Paste a string into Base64 to File or Base64 to Image to get the file back.
Image to Base64 PNG to Base64 JPG to Base64 PDF to Base64 MP3 to Base64 Video to Base64 Font to Base64 Base64 to File
Frequently Asked Questions
How do I convert a file to Base64?
Why is the Base64 string bigger than my file?
What is the difference between Base64 and a data URI?
data:image/png;base64, so browsers know the file type. Use the data URI in HTML and CSS and usually the plain string in JSON.