Skip to content
cosmodev ~/tools/base64

Base64 编码 / 解码

Encoders & Crypto

将文本编码为 Base64 或反向解码。UTF-8 安全,完全在浏览器中运行,并可通过链接分享你的精确输入。

Base64
输入或粘贴文本即可查看其 Base64。

功能说明

将文本转换为 Base64Base64An encoding representing binary data as 64 safe ASCII characters, so it survives transport through text-only channels. It encodes — it does not encrypt.,也可以反向转换回文本。选择编码或解码,粘贴你的输入,输出立即出现 - 不需要点击任何按钮。转换器支持多行输入,遇到无效的 Base64Base64An encoding representing binary data as 64 safe ASCII characters, so it survives transport through text-only channels. It encodes — it does not encrypt. 会明确报错而不是擅自猜测,还能把你的文本和转换方向一并保存在分享链接中,因此同事打开链接时看到的就是完全相同的转换。

使用方法

  1. 选择转换方向:编码(文本 → Base64Base64An encoding representing binary data as 64 safe ASCII characters, so it survives transport through text-only channels. It encodes — it does not encrypt.)或解码(Base64Base64An encoding representing binary data as 64 safe ASCII characters, so it survives transport through text-only channels. It encodes — it does not encrypt. → 文本)。
  2. 粘贴到输入框中。转换在你输入的同时即时进行。
  3. 复制输出结果,或者复制一条同时携带输入内容和转换方向的分享链接。
  4. 格式错误的 Base64Base64An encoding representing binary data as 64 safe ASCII characters, so it survives transport through text-only channels. It encodes — it does not encrypt.(错误字符、损坏的填充)会显示错误信息,而不是静默输出乱码 - 修正输入后,下一次按键即可恢复正常。

示例

方向 输入 输出
编码 Hello, CosmoDev! SGVsbG8sIENvc21vRGV2IQ==
解码 Q29zbW9MYWJz CosmoLabs
编码 multi\nline bXVsdGkKbGluZQ==

Base64Base64An encoding representing binary data as 64 safe ASCII characters, so it survives transport through text-only channels. It encodes — it does not encrypt. 是什么(又不是什么)

Base64Base64An encoding representing binary data as 64 safe ASCII characters, so it survives transport through text-only channels. It encodes — it does not encrypt. 把任意 3 个字节映射为由 64 个字母组成的字母表(A-Z、a-z、0-9、+、/,并用 = 填充)中的 4 个字符,这样二进制数据就能穿过只传输文本的通道 - data URL、JSON 字段、邮件的 MIME 部分、HTTP Basic 认证头。

有两个特性非常重要:

  • 它是可逆的,不是保密的。 任何人都能解码输出结果;不存在任何密钥。永远不要把 Base64Base64An encoding representing binary data as 64 safe ASCII characters, so it survives transport through text-only channels. It encodes — it does not encrypt. 当作加密手段,也不要当作隐藏凭据的方式。
  • 它会使数据膨胀约 33%。 3 个字节变成 4 个字符,所以 3 MB 的文件会变成 4 MB 的字符串。对令牌和小型载荷来说没有问题,对大型媒体则是糟糕的选择。

一个近亲是 Base64url(JWTJWTA compact, URL-safe token that carries claims (like identity or expiry) between two parties, signed to prevent tampering.Learn more 使用这种变体),它把 +→-、/→_,并去掉 = 填充,使字符串可以安全地放进 URL 中。本工具的解码功能接受普通 Base64Base64An encoding representing binary data as 64 safe ASCII characters, so it survives transport through text-only channels. It encodes — it does not encrypt.;处理 JWTJWTA compact, URL-safe token that carries claims (like identity or expiry) between two parties, signed to prevent tampering.Learn more 时请使用 JWT Debugger,它能够端到端地处理 base64url 变体。

补充说明

  • 无效输入(混入的杂散字符、被截断的填充)会显示 Invalid Base64 input - 转换器宁可拒绝猜测,也不输出乱码。
  • UTF-8 全程生效:带重音的字符和 emoji 都能正确地编码,并能正确地解码还原。
  • 私密: 转换在你的浏览器中本地运行。你粘贴的任何内容都不会被传输。
  • 相关工具: JWTJWTA compact, URL-safe token that carries claims (like identity or expiry) between two parties, signed to prevent tampering.Learn more Debugger、URL Encode / Decode、HashHashA one-way function that maps data of any size to a fixed-length digest. Same input, same digest; any change, different digest; not reversible. Generator。
源代码14 种语言

100% 客户端运行 · 你的数据永远不会离开浏览器。 觉得好用?分享给同事吧。