File to Base64
Convert any file into a Base64 string or a ready-to-use data URI β free and instant. The file is encoded right in your browser and never uploaded.
or click to browse β any file type Β· it stays on your device
How to convert a file to Base64
- Choose a file. Drag and drop any file β image, PDF, font, audio, anything β into the box above, or click to browse.
- Pick the output format. Choose plain Base64 for the raw encoded string, or Data URI to get a
data:mime;base64,β¦string you can paste straight into HTML or CSS. - Copy or download. Use the Copy button to grab the string, or download it as a .txt file for later use.
About this tool
Base64 is a way of representing binary data using only 64 safe ASCII characters, which lets you embed files inside text formats. Developers use this file to Base64 encoder to inline small images and icons into HTML or CSS as data URIs, embed fonts in stylesheets, put attachments into JSON or XML payloads, and prepare binary data for APIs that only accept text. The optional 76-character line wrapping matches the MIME standard used in email attachments.
The conversion runs completely in your browser with the FileReader API β your file is never sent to a server, so confidential documents are safe to encode. Note that Base64 output is about 33% larger than the original file, which is normal: every 3 bytes of data become 4 encoded characters.
Frequently asked questions
Why is the Base64 string larger than my file?
Base64 encodes every 3 bytes of binary data as 4 text characters, so output is always about 33% bigger than the input (plus a little more if line wrapping is enabled). That overhead is the price of making binary data text-safe.
What is a data URI and when should I use one?
A data URI is a string like data:image/png;base64,iVBORβ¦ that contains the whole file inline. Paste it into an <img src> attribute or a CSS url() to embed small images without a separate HTTP request. For files over roughly 10β20 KB, a normal linked file is usually better for performance and caching.
Is there a file size limit?
No fixed limit β encoding happens in your browser's memory. Files up to tens of megabytes work smoothly; very large files may make the page slow because the resulting string is huge. For long outputs the preview is truncated, but Copy and Download always contain the full string.
Is my file uploaded anywhere?
No. The file is read and encoded locally by JavaScript in your browser. Nothing is transmitted, stored or logged β the tool even works offline once the page has loaded.