URL Encoder / Decoder

URL 编码 / 解码

Percent-encode special characters in URLs, or decode %xx sequences back into readable text. Choose the mode that fits your input.

对 URL 中的特殊字符进行百分号编码,或将 %xx 序列解码为可读文本。根据输入选择合适的模式。

Encoding modes

编码模式

  • encodeURIComponent — escapes everything except A–Z a–z 0–9 - _ . ! ~ * ' ( ). Use for query parameter values and path segments.—— 转义除 A–Z a–z 0–9 - _ . ! ~ * ' ( ) 之外的所有字符。用于查询参数值与路径段。
  • encodeURI — preserves URL syntax characters like / : ? # & = + $ , ;. Use for full URLs where you want the structure intact.—— 保留 URL 结构字符 / : ? # & = + $ , ;。用于需要保留 URL 结构的完整链接。
  • decodeURIComponent — reverses percent-encoding on a string. Throws on malformed sequences such as %ZZ.—— 反向百分号编码。遇到 %ZZ 等非法序列会抛出错误。

Read the URL encoding deep dive for examples and pitfalls.

阅读 URL 编码深入解析 查看示例与常见坑。