Base64 vs URL encoding
Base64 vs URL encoding (percent-encoding) compared — what each does, output and use cases, with free encoders.
Base64 turns binary data into ASCII text (e.g. embedding an image in JSON); URL encoding (percent-encoding) escapes characters that are unsafe in a URL. They solve different problems and are often used together.
Base64 vs URL encoding at a glance
| Base64 | URL encoding | |
|---|---|---|
| Purpose | Binary → text | Make text URL-safe |
| Output | A-Z a-z 0-9 + / = | %XX escapes |
| Size | ~33% larger | Slightly larger |
| Use | Data URIs, tokens, email | Query strings, form data |
When to use Base64
Use Base64 to carry binary (images, files, keys) through text-only channels.
When to use URL encoding
Use URL encoding to safely put arbitrary text into a URL or query string.
Tools for Base64 & URL encoding
Base64 vs URL encoding
应该选择哪种编码模式?
在将文本嵌入 HTML 时,Minimal(最小集)模式就已经足够——它只转义 < > & " 和 '。Non-ASCII 模式适用于需要剔除高位字节的场景。All-known-named(全部已知命名实体)模式主要用于排版展示目的。
为什么有些字符用 &#x 表示,有些却用命名实体?
选择命名格式时,工具会优先输出对应的命名实体(如果存在);若没有对应命名实体,则会根据你选择的格式回退为十进制或十六进制形式。
那 XML 该怎么处理?
如果需要为 XML 转义,请使用我们的 Escape / Unescape 工具——XML 规范中只预定义了 < > & " ' 这几个内置实体。
有没有相关的工具?
可以查看 Escape / Unescape 工具,用于按编程语言规则转义字符串;以及 URL Encoder 工具,用于进行百分号编码(percent-encoding)。