URL 编码工具

将文本字符串或 URL 参数中的特殊符号与非 ASCII 字符转换为百分号编码(Percent-encoding)。接收原始文本输入,依据标准 RFC 3986 规范将其转义为安全可传输的十六进制序列。本工具仅执行字符转义,不校验转换后的参数在具体后端接口的业务有效性。

在需要传递参数时,如何安全进行 URL 编码

适用于在拼接 Web 链接、API 请求或重定向参数时对字符串进行百分号编码(Percent-Encoding)。默认模式遵循 URI 组件编码规范转换保留字符;同时提供全字符编码模式用于特殊协议或调试。处理纯在浏览器本地进行,不上传任何文本。

操作步骤

  1. 在输入框中粘贴需要编码的原始字符串或 URL 地址。
  2. 选择编码模式:默认保持“对非特殊字符进行编码”未勾选,使用标准 encodeURIComponent 转换路径及查询分隔符;仅在接收端明确要求每个字符均转为十六进制时才勾选该选项。
  3. 查看并复制输出区域的百分号编码文本;在目标系统或测试脚本中核对接收端能否按对应规则正确解码。

编码包含路径、空格及查询参数的完整请求地址

输入

https://example.com/search?q=hello world

选项

默认模式(未勾选“对非特殊字符进行编码”)

输出 / 解析结果

https%3A%2F%2Fexample.com%2Fsearch%3Fq%3Dhello%20world

限制与常见问题

  • 默认模式基于 encodeURIComponent,会对 :、/、?、=、&、# 以及空格(转为 %20)等字符进行标准 UTF-8 编码,保留字母、数字以及 encodeURIComponent 的未编码符号(-、_、.、!、~、*、'、(、))。
  • 勾选“对非特殊字符进行编码”后,将按字符 Unicode 码点直接拼装为大写十六进制 %XX。对于 ASCII 字符(如字母 A 转为 %41)符合单字节十六进制;但非 ASCII 字符(如汉字“中”得到 %4E2D、表情符号 😀 得到 %1F600)输出的是 Unicode 码点十六进制,并非标准 UTF-8 百分号字节串,不能保证通过 decodeURIComponent 正确还原。需要标准 UTF-8 百分号转义时请使用默认模式。
  • 编码是纯文本转换,不验证输入的 URL 是否合法有效或目标是否存在;如需组装复杂查询参数,建议结合 URL 编辑器核对参数名与值分别编码。

Safely URL-encode strings when constructing parameters

Use this tool to apply percent-encoding to strings when assembling web links, API requests, or redirect parameters. Default mode follows standard URI component rules; an encode-all mode is also available for specific protocol or debugging needs. All processing runs entirely in your browser without transmitting input text.

Steps

  1. Paste the raw string or URL into the input area.
  2. Select encoding options: keep 'Encode non-special characters' unchecked for standard encodeURIComponent behavior; enable it only when the receiving API requires full hexadecimal escaping.
  3. Review and copy the percent-encoded output, then verify that the target system decodes it correctly using matching rules.

Encode a URL containing path slashes, spaces, and query parameters

Input

https://example.com/search?q=hello world

Options

Default mode ('Encode non-special characters' unchecked)

Output / inspection

https%3A%2F%2Fexample.com%2Fsearch%3Fq%3Dhello%20world

Limits and common issues

  • Default mode uses encodeURIComponent to perform standard UTF-8 encoding on delimiters such as :, /, ?, =, &, #, and space (%20), while keeping alphanumeric characters and encodeURIComponent's unescaped symbols (-, _, ., !, ~, *, ', (, )).
  • Enabling 'Encode non-special characters' outputs each character's raw Unicode code point directly in hex prefixed with %. While ASCII characters yield single-byte hex (e.g. A becomes %41), non-ASCII characters (such as '中' yielding %4E2D or emoji 😀 yielding %1F600) emit code-point hex rather than standard UTF-8 multi-byte percent octets, which standard decodeURIComponent cannot restore. Use default mode when standard UTF-8 percent-encoding is required.
  • URL encoding is a string transformation and does not validate whether a URL exists or is reachable. When building query strings, encode keys and values individually to avoid escaping structural query separators unintentionally.