ToolGlint

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

  1. Choose File to Base64, then click the box to pick a file or drop one onto it.
  2. Pick Data URI to get a string you can paste straight into HTML or CSS, or Base64 only for the bare encoded data.
  3. Copy the result or download it as a text file. Images are previewed so you can check you chose the right one.
  4. To go the other way, choose Base64 to file and paste the Base64 or data URI into the left box.
  5. 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