Convert a File to Base64
Encode any file as Base64 or a data URI.
What does File to Base64 Converter do?
Convert any file — image, font, PDF, audio — into Base64 or a complete data URI for embedding in CSS, JSON, HTML or an API payload. The MIME type is detected automatically from the file itself.
How to Use File to Base64 Converter
- 1Select a fileAny type, any size within reason.
- 2Choose an output formatRaw Base64, data URI, CSS or HTML.
- 3Copy or downloadLarge results are easier to download.
Key Features
- Any file type, with the MIME type detected from the content
- Raw Base64 or a complete data URI
- CSS and HTML snippets generated for common asset types
- Encoded size shown, including the 33% overhead
- Warning when the result is too large to be worth inlining
- Download the Base64 as a text file for very large results
Frequently Asked Questions
When should I inline a file as Base64?
Only for small assets — icons and tiny graphics under a few kilobytes. Inlining removes a request but the data cannot be cached separately and is 33% larger, so it hurts more than it helps beyond that.
Why is the Base64 larger than my file?
Because Base64 represents three bytes as four ASCII characters. The output is always about 33% larger, plus a few bytes for the data URI header.
Can I embed a font this way?
Yes, and it eliminates a render-blocking request for a critical font. But fonts are typically 20–100 KB, so inlining bloats your CSS and prevents the font being cached across pages. Preloading is usually better.
Is the MIME type detected reliably?
It comes from the browser, which uses the file extension and content signature. The tool shows it so you can correct it if the data URI needs a different type.
Files are read directly from your device by the browser and processed in this page. Nothing is uploaded, which is why there is no progress bar and why large files are handled instantly.
Related Tools
Base64 to File Converter
Decode Base64 back into a downloadable file.
Image to Base64 Converter
Turn an image into a Base64 data URI for CSS, HTML or JSON.
Base64 Encoder
Encode text to Base64, with UTF-8 and URL-safe support.
Base64 Decoder
Decode Base64 back to readable text, standard or URL-safe.