Base64 编码器与解码器 - 文本与文件(支持 URL 安全)
将任意文本或文件编码为 Base64(或 data URL),或将 Base64 解码回文本——也可将其下载为原始二进制文件。支持 URL 安全变体。完整支持 UTF-8,全程在你的浏览器中运行。
在此粘贴文本或 Base64……
或拖入任意文件
Base64 编码/解码已完成?不妨试试这些
与 Base64 编码/解码搭配使用的精选工具。继续编辑,不丢失你的文件。
URL 编码器 / 解码器
对 URL 组成部分或整个 URL 进行百分号编码,并可解码还原。支持 encodeURIComponent 与 encodeURI 两种模式。
立即试用哈希生成器
使用浏览器的 Web Crypto API 计算任意文本或文件的 SHA-1、SHA-256、SHA-384 和 SHA-512 十六进制摘要。
立即试用JWT 解码器
解码 JSON Web Token,查看头部和载荷、检查过期时间。仅在本地运行——你的令牌绝不会离开浏览器。
立即试用JSON 美化
在浏览器中格式化、校验和压缩 JSON。可使用 2 / 4 / 8 空格缩进美化,或压缩为单行,并支持复制和下载。
立即试用密码生成器
生成长度可达 128 个字符的高强度密码学随机密码,并实时估算熵值。
立即试用文本差异比较
逐行比较两段文本。支持分栏或合并视图,可选择忽略空白和忽略大小写。
立即试用Frequently Asked Questions
将你的文本粘贴或任意文件拖入输入框,将模式保持在「编码」,Base64 表示形式便会出现在输出中。对于文件,你会得到一个可直接嵌入 HTML、CSS 或 JSON 的 data URL——中间无需任何上传服务器。
usageURL 安全的 Base64 会将「+」替换为「-」、「/」替换为「_」,并去除末尾的「=」填充,从而让编码后的值无需进一步转义即可用于 URL、文件名和 JWT 片段中。每当输出最终用于查询字符串、路径片段或 HTTP 标头时,请开启 URL 安全模式。
technical不能。Base64 是一种编码方式,并非加密。任何人都能一键解码出原始字符串,因此切勿将它当作保密手段。当你需要真正的机密性时,请使用 AES、RSA 或 libsodium,而 Base64 仅用于让二进制数据可安全地以文本形式传输。
privacyBase64 将三个字节打包成四个字符。当输入长度不是三的倍数时,编码器会用「=」填充最后一块,使输出保持为四的倍数。标准 Base64 保留填充;URL 安全的 Base64 则省略填充,因为其长度是隐含可推算的。
technical可以。编码器在编码前会将输入读取为 UTF-8,因此阿拉伯文、中文、西里尔文和表情符号字符都能干净地往返转换。解码结果会还原为 UTF-8 文本,这正是所有现代浏览器、终端和 API 所期望的。
compatibilityBase64 会让数据膨胀约 33%——每三个字节的输入会变成四个字节的输出。这对短令牌、小图标和嵌入 JSON 的缩略图来说没问题,但对于大型资源,最好直接上传二进制文件或使用 CDN 链接,以保持传输速度。
technical不会。编码器完全在你的浏览器内运行,使用标准的 atob / btoa API 并搭配 UTF-8 封装,因此你的文本或文件绝不会到达服务器。这让该工具对于令牌、凭据以及你不愿暴露的专有二进制文件都很安全。
privacy将模式切换为「解码」,粘贴你的 Base64 字符串,原始文本会立即显示在输出框中,可复制或下载为 .txt。如果该字符串使用 '-' 和 '_' 而非 '+' 和 '/',请开启 URL 安全模式以确保正确解码。
usageYes. Switch to Decode mode and paste the Base64 or data URL text — if it decodes successfully, a "Download as file" button appears next to the plain Download option. Clicking it writes out the exact original bytes with the extension detected from the embedded MIME type, so a base64-encoded photo or PDF comes back as a real, openable file instead of garbled text.
featuresDownload always saves the decoded output as a plain .txt file, which is right when the Base64 represents text. Download as file only appears when the decoded bytes are recognized as binary data — like an image or PDF — and it reconstructs the original file with its proper extension instead of dumping raw bytes into a text file that won't open correctly.
usageHow Base64 Encoder/Decoder helps you get it done
Real problems it solves every day — for businesses, creators, and everyday tasks. Find the use case that fits you and start in seconds.
将图片以 Data URL 形式嵌入 HTML 与 CSS
将小图标、徽标和 SVG 雪碧图内嵌为 Base64 数据 URL,减少 HTTP 请求,发送单文件 HTML 邮件,让原型无需外部资源托管即可自成一体
API 鉴权与 Bearer 令牌
构建 HTTP Basic 认证头、在 API 调试时解码 bearer 令牌,并查验 Postman、curl 示例和 OpenAPI 文档中以 base64 封装的凭证
为 JSON 与 GraphQL 载荷编码文件
将二进制上传内容(PDF、图片、音频片段)编码为 Base64 字符串,使其能安全地嵌入只能传输文本的 JSON、GraphQL 变更操作和 webhook 请求体中
解码电子邮件 MIME 附件
从原始 .eml 文件、SMTP 日志或 IMAP 响应中提取 Base64 编码的附件,从邮件导出文件中找回丢失的发票、截图和文档
适用于 Web 应用的 URL 安全令牌
为密码重置链接、邮件验证码、分享 ID 和短网址生成 URL 安全的 Base64 字符串,避免在浏览器中因「+」或「/」字符而出错
手动检查 JWT 各段
在本地调试时,若你的终端或编辑器中没有安装完整的 JWT 解码器,可在此解码 JSON Web Token 的头部与载荷部分
Store Certificates & Keystores in CI/CD Secrets
Encode SSL certificates, Android signing keystores or a GCP service-account JSON file to Base64 so they can be pasted into GitHub Actions, GitLab CI or Vercel environment variables that only accept plain text.
Rescue Files Shared as Raw Base64 Text
Paste a base64 blob copied from a Slack message, bug report or email into Decode mode and use Download as file to recover the original image or PDF someone sent you as text instead of an attachment.
Mock API Responses Without a Backend
Generate base64 placeholder images or binary payloads to drop straight into Postman collections, MSW handlers or Swagger examples while the real backend endpoint is still being built.
Debug Webhook Signature Payloads
Inspect the base64-encoded body Stripe, Twilio or another provider sends with a webhook so you can manually verify a signature or replay a payload while building an integration locally.
Pixoate