File Base64 Encoder & Decoder
Convert any file to Base64 or restore Base64 data into a downloadable file
File Base64 Encoder & Decoder — what it does
Encode any file into a Base64 string, or paste Base64 back and decode it into a downloadable file with the name and MIME type you specify. Base64 is how binary data travels through text-only channels — JSON payloads, data URIs, configuration files — and this tool covers both directions of the trip.
Worked example
A 79-byte memo.txt encoded, then decoded straight back with the fields the encoder filled in.
Input — memo.txt (79 bytes)
Team offsite 2026-11-14 Venue: Harbour Room, 9:30 start Bring laptop and badge
Output — Base64 box and the two fields after Encode
data:text/plain;base64,VGVhbSBvZmZzaXRlIDIwMjYtMTEtMTQKVmVudWU6IEhhcmJvdXIgUm9vbSwgOTozMCBzdGFydApCcmluZyBsYXB0b3AgYW5kIGJhZGdlCg== Output filename: memo.txt MIME type: text/plain Decode → downloads memo.txt, 79 bytes, identical to the original
The encoded string is a complete data: URL, not just the Base64 part, and Encode overwrites the Output filename and MIME type fields with the file's own name and type.
When this tool helps
- Embedding a small image or font as a data URI in CSS or HTML.
- Preparing a file payload for an API that accepts Base64 in JSON.
- Recovering an attachment from a raw Base64 block found in an email source or a log.
How to use it
- To encode: choose a file and copy the Base64 output.
- To decode: paste the Base64 string.
- Set the output filename and MIME type.
- Download the reconstructed file.
Accuracy, limits, and good practice
- Base64 inflates size by about a third; a 3 MB file becomes roughly 4 MB of text, which is why it suits small assets, not archives.
- Encode returns a complete data URI (data:, the MIME type, ;base64, then the encoded text); if a field expects only the raw Base64, delete everything up to and including the comma.
- When decoding, strip any surrounding quotes, line breaks from email wrapping, or a data URI prefix first if the result fails to parse.
Frequently asked questions
Is Base64 encryption?
No. It is a reversible encoding anyone can decode. It provides transport safety, not confidentiality.
Why did my decoded file not open?
Usually the wrong MIME type or a truncated string. Verify the Base64 is complete and set a type matching the original file.
What does the MIME type field do?
It labels the download so the operating system and browser know which application should open it.
Why does the encoded text start with data:text/plain;base64,?
The file is read as a data URL, so the box holds the MIME prefix plus the Base64 body. Paste the whole string where a data URI is expected — an img src or a CSS url(); for a bare Base64 value delete everything up to and including the first comma. Decode accepts either form.
What does Decode accept, and which MIME type is used?
Spaces and line breaks are stripped first, so Base64 wrapped by an email client decodes fine. If the text starts with data:, the MIME type inside it overrides the MIME type field; otherwise the field is used. Quotation marks or a truncated string make the browser's decoder fail and nothing is downloaded. The file is named after the Output filename field, or decoded-file when it is empty.
Related tools on this site
- Invoice Generator — Create a printable invoice with client details, line items, discount, tax, and totals
- Random Team Generator — Shuffle a name list and divide participants into balanced teams
- Wi-Fi QR Code Generator — Create a scannable QR code for Wi-Fi network credentials
Further reading: How Local Browser Tools Protect Your Files
Everything above runs inside this page. File Base64 Encoder & Decoder needs no account, no upload, and no server round trip — close the tab and nothing is left behind.
檔案 Base64 編解碼能做什麼
把任意檔案編碼成 Base64 字串,或貼回 Base64 解碼成可下載的檔案,檔名與 MIME 類型由你指定。Base64 是二進位資料通過純文字通道的方式——JSON 載荷、data URI、設定檔——本工具把來回兩個方向都包了。
實際範例
把 79 位元組的 memo.txt 編碼,再直接以編碼器填好的欄位解碼回原檔。
來源:memo.txt(79 位元組)
Team offsite 2026-11-14 Venue: Harbour Room, 9:30 start Bring laptop and badge
產生:按下 Encode 後的 Base64 方塊與兩個欄位
data:text/plain;base64,VGVhbSBvZmZzaXRlIDIwMjYtMTEtMTQKVmVudWU6IEhhcmJvdXIgUm9vbSwgOTozMCBzdGFydApCcmluZyBsYXB0b3AgYW5kIGJhZGdlCg== Output filename: memo.txt MIME type: text/plain Decode → downloads memo.txt, 79 bytes, identical to the original
編碼字串是完整的 data: URL,不只是 Base64 本體;按 Encode 會把檔名與 MIME 類型兩個欄位改成該檔案自己的名稱與類型。
什麼時候用得上
- 把小圖或字型以 data URI 內嵌進 CSS 或 HTML。
- 為接受 JSON 內 Base64 的 API 準備檔案載荷。
- 從郵件原始碼或日誌裡的 Base64 區塊還原附件。
使用步驟
- 編碼:選擇檔案並複製 Base64 輸出。
- 解碼:貼上 Base64 字串。
- 設定輸出檔名與 MIME 類型。
- 下載還原後的檔案。
精確度、限制與實務建議
- Base64 會讓體積膨脹約三分之一;3 MB 的檔案變成約 4 MB 的文字,所以它適合小型資產,不適合封存。
- 編碼結果是完整的 data URI(data:、MIME 類型、;base64,,再接編碼內容);若欄位只要純 Base64,請把逗號以前的部分(含逗號)刪掉。
- 解碼失敗時,先移除前後引號、郵件換行或 data URI 前綴再試。
常見問題
Base64 是加密嗎?
不是。它是任何人都能還原的可逆編碼,提供的是傳輸相容性,不是保密性。
為什麼解碼出的檔案打不開?
通常是 MIME 類型不對或字串被截斷。請確認 Base64 完整,並設定與原檔相符的類型。
MIME 類型欄位是做什麼的?
它標示下載檔的類型,讓作業系統與瀏覽器知道該用哪個程式開啟。
為什麼編碼文字開頭是 data:text/plain;base64,?
檔案是以 data URL 方式讀取的,所以方塊裡是 MIME 前綴加 Base64 本體。整串可以直接貼到需要 data URI 的地方,例如 img 的 src 或 CSS 的 url();只要純 Base64 的話,把第一個逗號(含)之前的部分刪掉即可。兩種形式 Decode 都接受。
Decode 接受什麼格式?MIME 類型以哪個為準?
會先去掉空格與換行,所以被郵件程式折行的 Base64 也能解。文字若以 data: 開頭,裡面的 MIME 類型會蓋過 MIME 類型欄位;否則採欄位的值。帶引號或被截斷的字串會讓瀏覽器解碼失敗,不會有下載。檔名取自檔名欄位,留空則叫 decoded-file。
本站相關工具
- 發票生成器 — 建立包含客戶、品項、折扣、稅額和總計的可列印發票
- 隨機團隊分組器 — 隨機打亂名單並平均分配為多個團隊
- Wi-Fi QR Code 生成器 — 為 Wi-Fi 網路名稱與密碼建立可掃描 QR Code
延伸閱讀: 本地瀏覽器工具如何保護你的檔案
以上步驟全部在這個頁面內完成,檔案 Base64 編解碼 不需要註冊、不上傳檔案、也不經過伺服器,關閉分頁後不會留下任何資料。