About File to Base64
File to Base64 converts a file into a Base64 data URL — a single text string beginning with data: followed by the file's MIME type and then the file's contents encoded as Base64. The result can be pasted directly into HTML or CSS, stored in a JSON field, or carried through any channel that accepts only text.
Base64 represents arbitrary binary data using nothing but printable characters, which is what makes the trick possible. The cost is size: Base64 spends four characters on every three bytes, so the encoded string runs about thirty-three percent longer than the file itself. A small icon becomes a manageable string; a large image becomes an enormous one, and very large files can produce strings long enough to slow the page down.
Two details are worth knowing. The MIME type comes from whatever the browser infers about the file, usually its extension, so it can occasionally be wrong or generic — the output falls back to application/octet-stream when the browser has no opinion. And the result is a data URL string rather than a downloadable file: you copy it and use it where the text is wanted. Everything happens locally and nothing is uploaded.
How to use File to Base64
- 1 Select the file you want to encode.
- 2 Run the tool to produce the Base64 data URL.
- 3 Copy the string and paste it where a data URL is accepted, such as an image src or a CSS url().
Frequently asked questions
Why is the Base64 string bigger than the file?
Because Base64 encodes three bytes as four printable characters, an overhead of about thirty-three percent. The data URL also adds a short prefix naming the MIME type. That expansion is the price of expressing binary data as text.
How big a file can it encode?
The tool imposes none of its own, but it holds both the file and its encoded form in memory, so the practical ceiling is what the browser tab can handle. Very large files produce very long strings and may be slow to generate and to copy.
How is the MIME type decided?
From whatever the browser infers about the file, normally based on the extension, falling back to application/octet-stream when it has no opinion. Because it is a guess, it can be wrong for unusual file types, in which case you can edit the prefix by hand.
Can I turn the data URL back into a file?
Not with this tool — it encodes one way only. Pasting the string into a browser address bar will often display the content directly, and a dedicated decoder can rebuild the original file from the Base64 portion.
Free, online, and private
Free to use
File to Base64 is completely free. There is no account to create, no login, and no hidden charge or usage limit.
Runs online in your browser
It is a free online tool that runs entirely in your browser. Nothing to download or install — open the page and start using it right away.
Your data stays private
All processing happens locally on your device. Your input is never uploaded, stored, or tracked, so it never leaves your browser.
How File to Base64 behaves in detail
These are the specifics of this implementation — the exact ranges, defaults and fixed settings you are working with.
| Parameter | Value |
|---|---|
| Output shape | a complete data URL: data:<MIME>;base64,<string> |
| MIME source | the browser's file.type, falling back to application/octet-stream when it is empty |
| Alphabet | standard base64 using + and /, padded with = |
| Byte handling | arrayBuffer(), then converted 32768 bytes at a time so the fromCharCode call stays small |
| Image preview | an image MIME type makes the result render as a picture instead of a text box |
| No file chosen | the single line Choose a file first |
Compiled from the implementation of this tool and checked against it by itoolnet.
What File to Base64 does not do
Knowing the edges of a tool saves more time than another list of its features. These are the cases where it will not do what you might expect.
- The result is a data URL, not bare base64. If another form or an API expects only the part after the comma, the data:<type>;base64, prefix has to be stripped by hand, because there is no switch to leave it off.
- The whole file is loaded and then expanded into a string. Base64 holds four characters for every three bytes, so the output is about a third longer than the file and both the byte array and the string are alive at the same time.
- There is no size check and no way to save the result as a file. The string lands in the result box as text, so a large file produces a block that is awkward to select and copy, and an image type renders as a preview with the base64 hidden until you copy it.
Tested and documented by itoolnet, the team that builds and maintains this site.