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.
-
为什么要 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%xxform so your server can reliably read them. -
常见区别:encodeURI vs encodeURIComponent
·encodeURIComponent:更「激进」,会编码= & ? /等,适合只对参数值进行编码。
·encodeURI:保留 URL 结构相关的字符(如:/?&#),适合对整条 URL 进行处理。
· 解码时通常使用同一套函数的反向操作:decodeURIComponent/decodeURI。
For full URLs, preferencodeURI. For parameter values, preferencodeURIComponent. -
常见使用场景 · 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.
