How to use File to Base64
- Choose a file, or drop it onto the pane. Any type is accepted, up to 20 MB.
- Output: a Data URI (
data:<type>;base64,…), plain Base64, Base64URL, or Base64 wrapped at 76 characters. - Copy the result, or Download it as a text file.
Example
The sample is this site’s 418-byte SVG icon. Its status line reads SVG image · 418 B → 586 characters, and the output starts:
data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmci…
Base64 turns every 3 bytes into 4 characters, so the encoded text is about a third larger than the file, plus the short data: prefix.
When to use it
- Embedding a small font, icon or PDF in HTML, CSS or a JSON config.
- APIs that take file uploads as Base64 fields, such as email-sending services, document-signing APIs or the GitHub contents API.
- Test fixtures: a small binary file kept inline in a unit test.
Large data URIs make pages slower because the file can’t be cached separately; the tool warns above 1 MB.
Size and limits
Base64 output is always about 4/3 of the file size: a 300 KB PDF becomes roughly 400,000 characters. The output pane shows the beginning of very large results, but Copy and Download always include the whole encoded text. Files up to 20 MB are accepted, which covers almost every attachment-sized API payload.
Because the file never leaves your browser, this is a safe way to prepare private documents such as contracts, ID scans or certificates for an API call. Nothing is logged or stored, and closing the tab discards the file and its encoding. To check the result before sending it, paste the output into Base64 to File, which should report the same type and size as the original.
Related tools
Decode Base64 back into a file with Base64 to File, which detects the type from the bytes. For text rather than files, use Base64 Encode / Decode. For images with ready-made CSS and HTML snippets, use Image to Base64.
Frequently asked questions
Which files can I encode?
Any file up to 20 MB: PDFs, ZIPs, fonts, audio, Office documents, certificates or plain text. For images there is also Image to Base64, which can wrap the result as CSS, HTML or Markdown.
How is the MIME type in the data URI chosen?
From the file's first bytes (its signature): %PDF means application/pdf, PK with word/ inside means a DOCX, wOF2 a WOFF2 font, and so on. If the bytes are plain text with no signature, the type your browser reported (for example text/css) is used. When the browser's type disagrees with the bytes, the bytes win and a warning says so.
What is the difference between Base64 and Base64URL?
Base64URL replaces + and / with - and _ and drops the = padding, so the result can sit in a URL or a JWT without escaping. Standard Base64 is what data URIs, email attachments and most APIs expect.
What are the 76-character lines for?
MIME (email) and PEM files wrap Base64 at 76 characters per line. Use that style when pasting into an email source or a PEM-like block; everything else accepts a single line.
Is my file uploaded?
No. The file is read and encoded in your browser. It never leaves your device, which matters for contracts, keys and other private documents.
Last updated