File to Base64 converter
Read a local file as Base64 or a Data URL, or turn Base64 text back into a downloadable file — everything happens locally in your browser.
Runs in your browserEvery computation happens in your browser — your data never leaves this device.
Files are read locally in your browser and never uploaded.
No file selected yet. The file is read locally in your browser and never uploaded.
What this tool does
- Turn a small image, font or PDF into Base64 or a Data URL and inline it in CSS, HTML or JSON to save an extra request.
- Restore a Base64 field from an API response into a downloadable file and check whether it really is an image or a truncated mess.
- Inspect `data:image/png;base64,...` strings found in raw email, logs or packet captures to see the real type and size.
- Paste a self-contained icon into a document or ticket without attaching a file.
Example
Input
Hello, UniKit!
Output
SGVsbG8sIFVuaUtpdCE=
This is that text read as UTF-8 bytes and then encoded as standard Base64. In file mode you pick a file and copy the output; only the source of the bytes changes, the algorithm is identical.
Frequently asked questions
Can I convert big files — will the page die?
It works, but Base64 inflates the payload by roughly a third, and files over 2 MB also mean an extra copy of the string in memory, so the page warns you. Icons and fonts of a few hundred KB are fine; for tens of megabytes of video, referencing the file directly beats a Data URL.
What is the difference between a Data URL and raw Base64?
A Data URL prepends metadata: `data:<MIME type>;base64,`. Browsers can use it directly as an image or font, while raw Base64 is just characters and you have to supply the MIME type yourself. Decoding here accepts base64 Data URLs only — a plain-text Data URL such as `data:text/plain,abc` is rejected with “Only base64 Data URLs are supported”.
How is the decoded file type determined?
With a Data URL, the MIME type is read from the header. With bare Base64, it is guessed from the extension of the download name you typed (`logo.png` → image/png), falling back to application/octet-stream. The bytes always match what the Base64 decodes to — the extension only affects how your system opens it.
Why does the preview say “binary content — no text preview available”?
Because the decoded bytes are not valid UTF-8 text (a PNG header, for example). That is only a preview limitation: the bytes are complete, and clicking “Download file” gives you a byte-perfect copy.
Are files uploaded anywhere?
No. The file is read locally into a byte array via the browser FileReader, and encoding, decoding and download all happen locally through Blob and an object URL. No network request is made and no copy reaches a server.
Keywords:base64filedata url文件转换编码下载encodedecodefile to base64base64 to file