跳到主要內容

Base64 編碼/解碼

Base64 編碼/解碼

Base64 編碼/解碼: 支援文字與二進位資料的 Base64 編碼與解碼,提供 URL-safe 及 MIME 格式選項。支援 Data URL 解析、逐行編碼及自動格式辨識,適用於 API 呼叫、郵件附件及資料嵌入。

Base64 編碼/解碼

快速開始

1
在文字框輸入內容(一般文字或 Base64 字串)
2
點擊「編碼」或「解碼」開始處理
3
輸入與結果共用同一文字框,可一鍵複製或清空
4
需要驗證時:編碼後切換到解碼進行往返檢查
5
Choose Text mode for UTF-8 strings, or switch to Image mode for image files and image Data URLs
6
In Image mode, upload a file to generate a Data URL or raw Base64 result immediately
7
Paste a Data URL or raw Base64, choose MIME when needed, then reconstruct the preview

常見使用情境

URL/JWT

優先使用 URL‑safe 變體(−/_),必要時可移除結尾「=」填充,避免連結轉義問題

郵件/MIME

需要換行時採用 MIME 76 欄(CRLF)規則;網頁傳輸一般不換行。本工具提供 76 欄換行與 LF/CRLF 切換開關

多行文字

啟用逐行編碼,每行獨立輸出

MIME/PEM

啟用 76 欄換行;需要 LF 行尾時一併啟用

Data URL

嵌入時產生 data:[mime];base64,…;解碼會自動擷取逗號之後的內容

往返校驗

編碼後立即解碼,確認還原一致

Image upload

Keep the original bytes and switch between Data URL and raw Base64 output without re-uploading

Image Data URL

Paste data:image/...;base64,... to auto-detect MIME and rebuild a previewable image

Raw Base64 image data

Supply the original image MIME explicitly before reconstructing or downloading

補充場景

Base64 轉換、文字轉 Base64、圖片轉 Base64 也可在同一流程中完成,便於在複製、匯出或交付前快速核對結果。

編碼參數與變體

URL‑safe 輸出
逐行編碼(每行獨立)
依 MIME 76 欄換行(CRLF)
換行使用 LF(\n)
Data URL
Raw Base64
Raw Base64 image input needs an explicit MIME type because Base64 itself does not store file format metadata
自動補齊 padding:長度對齊 4 倍數;非法長度會提示
忽略空白:解碼時自動移除換行與空格

使用建議

統一使用 UTF‑8,避免出現亂碼
預設為 URL‑safe;若需標準 Base64,請在設定中關閉
跨系統傳遞時建議移除換行與空白;僅為排版時再加入
經 Base64 後資料量約增 33%,不適合處理大型檔案
標準 Base64(舊系統):關閉 URL‑safe(保留 +/ 與 =)
逐行編碼會對已編碼內容再次編碼;若僅需變體轉換,請關閉後再執行
76 欄換行僅影響顯示;解碼會忽略換行與空白
When sharing raw Base64, keep the original MIME type with it so the receiver can reconstruct the file correctly
Preview availability depends on browser image support; if preview fails, download still keeps the original bytes

限制與相容性

超長文字可能影響效能,建議分段處理
二進位:本介面以文字為主,二進位建議改用 Data URL 或指令工具
瀏覽器記憶體限制會影響可處理大小
Some image formats may encode successfully but remain unpreviewable in the current browser

會話管理

目前內容可隨時替換、清空並重新處理,匯出最終結果前可反覆檢查。
安全提醒:Base64 為編碼而非加密。涉密情境請先加密再編碼

常見問題

6

可繼續使用這些相關工具,完成後續步驟。