URL Encode / Decode|URL 编码与解码工具

URL Encode / Decode|URL 编码与解码工具

URL Encode / Decode URL 编码与解码工具

将文本或 URL 进行「编码」或「解码」,避免中文、空格、特殊符号在拼接链接、GET 参数时导致错误。
Encode or decode a URL or any text string so that spaces, non-ASCII characters, and symbols are safely used in links and query parameters.

1. 输入内容 · Input Text / URL
适用场景:
· 将包含中文或特殊字符的参数拼进 URL 前,先进行「编码」。
· 把浏览器地址栏中看到的 %E7%BC%96%E7%A0%81 这类字符串「解码」回可阅读文本。

Use cases:
· Encode text with non-ASCII characters before appending it to a URL.
· Decode percent-encoded strings like %E7%BC%96%E7%A0%81 to human-readable text.
encodeURIComponent:假定输入是「单个参数值」,会编码 = & ? / 等符号,适合 GET 参数。
encodeURI:假定输入是「完整 URL」,不会编码 :/?&# 等保留字符,适合整条链接。

encodeURIComponent is ideal for parameter values.
encodeURI is better for a full URL string.
3. URL 编码小知识 · URL Encoding Basics
  • 为什么要 URL 编码? · Why do we need URL encoding?
    URL 只能安全地传输有限字符集(英文字母、数字和少量符号)。中文、空格或部分符号在传输时可能被截断或误解析, 通过 URL 编码可将这些字符转换成 %xx 形式,保证服务器端能正确接收与解析。
    URLs only support a limited safe character set. Non-ASCII characters and spaces may break a URL or be mis-parsed. URL encoding converts them into %xx form so your server can reliably read them.
  • 常见区别:encodeURI vs encodeURIComponent
    · encodeURIComponent:更「激进」,会编码 = & ? / 等,适合只对参数值进行编码。
    · encodeURI:保留 URL 结构相关的字符(如 :/?&#),适合对整条 URL 进行处理。
    · 解码时通常使用同一套函数的反向操作:decodeURIComponent / decodeURI
    For full URLs, prefer encodeURI. For parameter values, prefer encodeURIComponent.
  • 常见使用场景 · Typical use cases
    · 手动拼接 GET 参数、分享链接时,保证链接在不同浏览器与系统中都能正常打开。
    · 调试接口时,将接口返回的编码字段解码,便于阅读或日志分析。
    · 前端或后端开发中,需要对重定向 URL、回调地址等进行安全处理。
    Use this tool whenever you need to build, debug, or inspect URLs that contain non-ASCII or reserved characters.

说明:本工具基于浏览器的 JavaScript encodeURI / encodeURIComponent / decodeURI / decodeURIComponent 函数, 默认以 UTF-8 编码处理文本,仅用于学习与开发辅助,不构成任何安全或合规承诺。
Note: This tool relies on the browser’s native JavaScript encoding/decoding functions under UTF-8. It is intended for learning and development convenience only and does not constitute any security or compliance guarantee.