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.

File to Base64 Converter with ShrinkBee

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

  1. Choose any file: Click the box above or drag the file onto it.
  2. Wait a moment: The file is encoded right away – usually in well under a second.
  3. 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.
  4. 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?
Choose or drag a file into the box above. It is encoded at once, and you can copy the plain Base64 string, the data URI or the ready-made HTML or CSS code.
Why is the Base64 string bigger than my file?
Base64 writes every 3 bytes as 4 text characters, so the result is about 33% larger. The file itself does not change, and decoding gives back the exact original.
What is the difference between Base64 and a data URI?
The Base64 string is just the encoded data. A data URI adds a prefix like 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.
Which file types are supported?
Any file. Images, PDFs, audio, video and fonts also get ready-made HTML or CSS snippets; other files get the data URI and the plain string.
Is there a size limit?
You can encode files up to 100 MB. For embedding in web pages, keep files small – ideally under 100 KB – so pages stay fast.
Can I turn the Base64 back into a file?
Yes. Paste the string into Base64 to File and download the original file again.
Is File to Base64 free to use?
Yes. File to Base64 is completely free, with no sign-up, no watermark and no limit on how many times you use it.
Are my files uploaded to a server?
No. Your files are processed directly in your web browser on your own device. Nothing is uploaded or stored, and the file is gone from memory when you close the tab.

More Base64 Tools

Made With ♥ By ShrinkBee