File to Base64
Convert an image or any file to a Base64 string or data URI, and turn Base64 back into a file. Runs in your browser.
File
Runs in your browser. Nothing you enter is uploaded or stored.
How to use the File to Base64
- Choose File to Base64, then click the box to pick a file or drop one onto it.
- Pick Data URI to get a string you can paste straight into HTML or CSS, or Base64 only for the bare encoded data.
- Copy the result or download it as a text file. Images are previewed so you can check you chose the right one.
- To go the other way, choose Base64 to file and paste the Base64 or data URI into the left box.
- Check the detected file type and size, then press Download file to save it.
Questions and answers
- Is my file uploaded?
- No. The file is read and encoded by your own browser, and decoding works the same way. Nothing is sent to a server, stored or logged, so the tool is safe for private images and documents.
- What is a data URI?
- A data URI holds a whole file inside a URL. It starts with “data:”, then the file type, then “;base64,” and the encoded data. A browser treats it like a link to the file, so you can use one as an image source in HTML or as a background in CSS without a separate file.
- When should I embed an image as Base64?
- It suits small images such as icons, logos in email signatures and tiny backgrounds, where saving a request is worth it. Avoid it for large images: Base64 is about a third bigger than the file, cannot be cached on its own, and makes the HTML or CSS that carries it slower to load.
- Why is the Base64 larger than my file?
- Base64 writes every three bytes as four text characters, so the result is always about 33% larger than the original. That is the price of turning binary data into plain text that can travel through JSON, HTML and email.
- What is the largest file I can convert?
- Five megabytes. The limit keeps the page responsive, since the encoded text has to be shown in a text box. Base64 is rarely the right choice for anything larger.
- How does it know the file type when decoding?
- If the text is a data URI, the type is read from it. Otherwise the tool looks at the first bytes of the decoded data, where formats such as PNG, JPEG, GIF, WebP, PDF and ZIP identify themselves. If neither helps, the file is saved with a .bin extension and you can rename it.
Related tools
Base64 Encode and DecodeEncode text to Base64 or decode it back in your browser, with full UTF-8 support. Free, instant and nothing is uploaded.URL Encode and DecodePercent-encode text for use in a URL or decode an encoded URL back to readable text. Free and runs in your browser.HTML Entity Encode and DecodeEscape special characters to HTML entities or convert entities back to plain text. Free and runs in your browser.Unicode Escape and UnescapeConvert text to Unicode escape sequences and code points, or turn escaped sequences back into readable characters.Text to Hex and BinaryConvert text to hexadecimal, binary or ASCII codes and back again. Free, instant and runs entirely in your browser.