Base64 是什么?在线编码解码与 URL 安全模式详解

What Is Base64? Encoding, Decoding, and URL-Safe Mode, Explained

Base64 是什么

Base64 是一种把任意二进制数据翻译成 64 个可打印字符的编码方式。它不是为了保密,而是为了让数据能在只认文本的通道里安全传输——比如邮件、JSON、URL,以及 HTML 里内嵌的小图片。

这个工具能做什么

打开 Base64 编解码工具:粘贴任意文本即可编码,粘贴 Base64 字符串即可解码,结果一键复制。工具同时提供两种字母表:

  • 标准模式:使用通用字母表,字符包含 + / =。
  • URL 安全模式:把 + / 换成 - _ 并去掉填充的 =,放进链接或 JWT 里不会被转义破坏。

关键认知

  • Base64 不是加密:任何人用同样的工具都能一秒解码,它只是"换一种写法"。敏感信息必须先加密再编码。
  • 体积会膨胀:编码后约为原来的 4/3,传输图片等大文件之前要权衡。
  • 解码失败怎么办:通常是多了空格、换行,或使用了错误的字母表。

典型用法

数据 URI 内嵌小图标、JWT 的分段表达、把二进制字段塞进纯文本协议——这些场景里 URL 安全模式都更稳妥。全部处理都在本地完成。

What is Base64?

Base64 is an encoding that translates arbitrary binary data into 64 printable characters. It is not about secrecy — it exists so data can travel safely through text-only channels: email, JSON, URLs, and small images embedded in HTML.

What this tool does

Open the Base64 encoder: paste any text to encode, paste a Base64 string to decode, and copy the result in one click. Two alphabets are available:

  • Standard mode — the common alphabet, including + / =.
  • URL-safe mode — swaps + and / for - and _ and drops the = padding, so the result survives links and JWTs without escaping.

Key facts

  • Base64 is not encryption — anyone can decode it with the same tool. Encrypt first, then encode.
  • Size overhead — output is about 4/3 the original; weigh that before shipping large files.
  • Decode failures — usually stray spaces, line breaks, or the wrong alphabet.

Typical uses

Inline icons via data URIs, JWT segments, and squeezing binary fields into text protocols — URL-safe mode is the safer choice in all of these. Everything runs locally.

Open the tool打开工具