YourTools.
简体中文
Back to the catalog
Tools

Image or file to Base64

Encode images or any other file as Base64 or as a data: URI to paste into HTML, CSS or JSON.

Process locally

Files stay in this browser session. Closing or clearing releases them.

Choose files

Any file, up to 10

Drop files here, or

Adjust settings

Optional: Add the data:…;base64, prefix, Line length

Image or file to Base64

Run

Processes in this browser; cancel at any time

Choose files first

About this tool

Convert an image or any other file to Base64. Use it to embed a small icon in HTML or CSS as a data: URI, to put a picture into a JSON request that expects Base64, or to store a file in a config that only takes text.

Any file type works, up to 10 files and 10 MB in total. By default the result starts with a data: prefix whose type is detected from the file's content or name. Everything runs in your browser, and the files are not uploaded.

How to use it

  1. Choose up to 10 files of any type, or drop them on the page. You can also select Use example to try a sample image.
  2. Leave “Add the data:…;base64, prefix” on for HTML and CSS, or turn it off to get plain Base64. Set “Line length” to “One line”, “64 (PEM)” or “76 (MIME)”.
  3. Select Run.
  4. Preview the beginning of the result, then download base64.txt for the full text.

Formats and limits

Input
Any file, up to 10 files
Output
Plain text
Size limit
10 MB in total
Settings
Add the data:…;base64, prefix; Line length (One line, 64, 76)
Privacy
Files stay in the current browser session. No file bytes are uploaded.
Price
Free, no sign-up

Common questions

Why is the Base64 cut off in the preview?

The preview shows only the first 20,000 characters, and Base64 is about a third larger than the original, so any file over about 15 KB fills it. Download base64.txt to get the complete text.

Can I convert files other than images?

Yes. Any file type works, for example PDF, font or ZIP files. The type in the data: prefix comes from the file's content when it is recognized, and from the file's name otherwise.

What happens when I convert several files?

All results go into one base64.txt. Each file's Base64 comes after a line with # and the file name, and a blank line separates the files.

When should I break the Base64 into lines?

Keep “One line” when you paste into CSS or JSON, where a string cannot contain line breaks. “64 (PEM)” and “76 (MIME)” split the text into lines of that length, as used in PEM files and email attachments.

How do I turn Base64 back into a file?

Use the “Base64 to image or file” tool. It accepts plain Base64 or a data: URI.